Regarding:

Anderson, James H (IT) wrote:
> I guess I forgot to mention the context. I'm interested in doing this 
> from the cmd shell.
>
>   
James,

You can use the command
  
     pragma count_changes=1

in the shell to have it report the number of rows affected by insert,
update, or delete statements (see
http://www.sqlite.org/pragma.html#modify for details).
======================
======================

But if you're using the command-line demonstration program, I don't
think the pragma will help you.

Since the command shell program (sqlite3.exe) doesn't attempt to
implement a procedural language (variables, loops, ,etc)  I don't know
that you could do what you need to do with the count anyway.

You *may* find that if you replace your single selects with:
     Select 'The count is ',  count(*) from blah, blah, blah.   --
perform select just to get a count
     Select * from blah, blah, blah                             -- this
time for real
The second select goes much faster because of caching.

Or maybe run a test with EXPLAIN QUERY PLAN as prefix to the select in
order to be sure it's using the indicies you expect -- maybe
*everything* can be made much faster.

A fancier option would be to cache the results of your select into a
temporary table, such as:
      CREATE TEMP TABLE stuff_temp AS SELECT blah, blah, blah;
      SELECT 'The count of stuff is', SELECT COUNT(*) FROM stuff_temp;

      You might look at "PRAGMA temp_store" to optimize handling of
temporary tables.

I think that the command line sqlite3.exe was mainly intended as a
demonstration and a testing tool -- most users want to link the library
into a language of their choice -- all the more true if speed is
particularly important.

Don't get me wrong; I myself love to mess with sqlite3.exe and create
crazy batch files. ;-)



[opinions are my own, not necessarily those of my company]

-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to