Re: Prepared Statement



I could not quite understand your concern ;-) but let me try..

A query plan is generated each time a query needs to be executed. What
we do with a prepared stmt is to prevent generation of this query plan
each time.

The query plan is placed in the cache of the database for some time
which is configured by the DBA.

When your code opens a connection, and tries to execute the stmt, it
first searched in the cache for the statement and if it finds it ,
executes it...and gets data from the database.

A pointer to a result set will not exist if you close the connection
itself. Hence, the actual result set could be somewhere on the DB cache
and the interface Result set could be just a pointer to that memory
..... this is a part I am also little bit confused about

.



Relevant Pages

  • Re: tempdb usage.
    ... You can run a query plan before you execute your script to see how much ... I/O cost you will have. ... Click on query plan again to execute normally. ...
    (comp.databases.sybase)
  • Re: Why running the same query after the first time is faster ?
    ... The other problem might be the query plan. ... You could clear the disk cache by doing a different query. ... >> Most likely it is cache, as Michael said. ...
    (microsoft.public.sqlserver.programming)
  • Re: Java SQL interface
    ... Who decides how long a query plan resides in the ... DB cache in case of a SQL statement being fired ... If the DB even makes use of a query plan, in most cases it's the DB itself ...
    (comp.lang.java.databases)