On Tue, Jun 11, 2013 at 9:08 AM, Igor Tandetnik <i...@tandetnik.org> wrote:

> On 6/11/2013 9:01 AM, Simon Slavin wrote:
>
>> The only time that _prepare() will use a lot of memory is when it has to
>> generate a temporary index because you have not created a table index
>> suitable for the WHERE and ORDER BY clauses.
>>
>
> I'm pretty sure this would happen on the first _step(), not on _prepare().
> Prepare is always nearly instantaneous.
>


Correct.

Think of sqlite3_prepare() as the compiler that converts your SQL program
into machine language (really byte-code in the case of SQLite).
sqlite3_step() runs your program up to the next breakpoint, which is the
spot in which the first row of output is computed, or until the program
exits.  SQLITE_ROW is returned if it hits a breakpoint and SQLITE_DONE is
returned on exit.

Creating of temporary indices happen when the program is run, not when it
is compiled.  That means it happens during sqlite3_step().

sqlite3_prepare() == running the compiler
sqlite3_step() == running the compiled binary

NB:  There are some PRAGMA statements that cheat and take effect during the
compilation step.  But all "regular" SQL statements obey the rules above.
-- 
D. Richard Hipp
d...@sqlite.org
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to