db-derby-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Knut Anders Hatlen <knut.hat...@oracle.com>
Subject Re: Question about prepared statements
Date Thu, 22 Jul 2010 08:01:17 GMT
Marco Ferretti <marco.ferretti@gmail.com> writes:

> Hello, 
> I have a question on how derby works with prepared statements.
> The scenario : 
> -1 connection (embedded driver)
> -1 prepared statement run several times over the database ( does not matter if
> select, insert ... ) 
> -I keep the connection open but close the prepared statement ( and make sure
> it is garbage collected )
> -On a later stage I create a new prepared statement with the same SQL as the
> one mentioned before 
> Question :
> Does derby re-use the pre-compiled SQL or is it creating another one ?

Hi Marco,

Derby keeps a cache of the most recently compiled statements (100 by
default, tunable with the derby.language.statementCacheSize property),
so if you later prepare a statement with the exact same SQL text, you'll
most likely re-use the pre-compiled SQL from the cache.

Knut Anders

View raw message