dimanche 3 mai 2015

jdbc keep prepared statement in memory?

I'm using a prepared statement for my sqlite logging database.

My thread runs every 50ms to write things in the log buffer to the database.

Currently i'm making a new prepared statements batch on every thread run and closing them after all the data lines are written.

Now i'm wondering if its better to keep the prepared statement in memory and close it only when the thread closes/is interrupted?

The reason i'm doing this pre-optimisation is because I want this logging thread to be as least as intrusive on main app performance as possible and I can imagine allocating/parsing/verifying resources every 50 seconds may be more intensive than to keep the prepared statement in memory.

In the end I think i'll need about 20-30 prepared statements on my database for the various log types. So would it be better just to initialise these when needed as new prepared statements or should I just initialise them once and keep the prepared statements in memory?

Aucun commentaire:

Enregistrer un commentaire