The prepare creates a virtual machine which can be rused. A useful way
to implement Sqlite is to use prepare to compile all the SQL in the
initialization phase of the program and then to execute the virutal
machines using step.
By compiling a SQL in advance you can ensure that the program will not
fail in mid execution with an SQl error.
Uma Krishnan wrote:
In SQLite3 one uses prepare/step to execute query. The question that I have is,
when your stepping yields no more rows, and one has to re-execute the query,
does one have to call the prepare statement again. If that's the case, what's
the advantage of pre-compiling. If not, how does Sqlite3 knows it has to
reissue the query.
In standard DB/JDBC parlance, one prepares (one time, unless recompiled),
executes, loops for next (/step) until all rows fetched, then closes.
Subsequently one can skip prepare and proceed to execute.
Thanks in advance
Uma
Uma Krishnan <[EMAIL PROTECTED]> wrote: Yes. Makes sense (not to cache query
results for embedded apps). So what is cached. Just dirty pages? or are raw tables
cached when queried?
Thanks
Uma
Scott Hess wrote: On 10/17/07, Trevor Talbot wrote:
On 10/17/07, Uma Krishnan wrote:
One other question, when a query is issued, does SQLite cache the results, so
that future queries can be processed off the cache (I think not)
Like the "query cache" in some other databases? No.
SQLite does have a cache of database pages, but they mimic what's on
disk, not the results of a particular query.
A query cache would not be very useful for an embedded database. If
you're caching results, you might as well do it in the application's
native form -- it's the same process after all.
To add another nail, the reason a query cache is often useful in
database servers is because you can usually share the cache across all
the front-ends. Since SQLite effectively lives inside the front-end,
this sharing goes away. Worse, any caching SQLite does is adding to
the memory footprint of the containing app (or, put another way,
stealing memory the app could use in other ways).
-scott
-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------