Thanks a lot for your quick answer !!

On Thu, Jul 22, 2010 at 10:01 AM, Knut Anders Hatlen <knut.hatlen@oracle.com> wrote:
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