empire-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Harald Kirsch <Harald.Kir...@raytion.com>
Subject Re: prepared statements best practices
Date Tue, 14 May 2013 08:06:11 GMT
Hi Rainer,

my main concern was indeed whether it is necessary to keep the DBCommand 
object in order for the backend database keep the prepared statement around.


On 14.05.2013 09:15, Rainer Döbele wrote:
> Hi Harald,
> I would not recommend keeping a DBCommand for longer than the current context.
> Creating a command object is cheap and it does not influence the prepared statement caching
in any way.
> However I would recommend to reuse the DBCommand and modify the param values directly
in cases where you locally execute the same statement multiple times with varying param values
as indicated in the example.
> On the other side, there is nothing that restricts you from reusing a DBCommand object.
> You might even store it on session scope. However be aware that modification of the command
object is not thread safe.
> Regards
> Rainer
>> from: Harald Kirsch [mailto:Harald.Kirsch@raytion.com]
>> to: user@empire-db.apache.org
>> re: prepared statements best practices
>> Hi there,
>> what are considered best practices for reusing DBCommand objects, in
>> particular when they contain prepared statements or, rather, had
>> addParam() called. Is it recommended to reuse the objects and just change
>> the parameters?
>> In the SampleAdvApp only the parameters are changed. But I would like to
>> be sure that this is not only done because the object is on the stack anyway.
>> What if I would need to store it, typically in a ThreadLocal. Is that worth the
>> effort given that I am feeding 40 million rows into the DB?
>> Thanks,
>> Harald.
>> --
>> Harald Kirsch
>> Raytion GmbH

Harald Kirsch
Raytion GmbH
Kaiser-Friedrich-Ring 74
40547 Duesseldorf
Fon +49-211-550266-0
Fax +49-211-550266-19

View raw message