
On 12-11-2010 20:46:51 +0100, Stefan Manegold wrote:
You really want to make a million prepared statements here? The server has to store them all... I guess so, since you're leaking prepared handles like mad
We create separate PreparedStatement for every query in our project. There are no memory leak on the client side (we close every PreparedStatement). Why server should store PreparedStatement forever, is it possible to configure server do not store them? Or it works so by design, and we should cache our PreparedStatements.
The idea of prepared statements is to prepare a query template once and then call (re-use) it with different parameters multiple times, i.e., for 1000 inserts you would to one prepareStatement (and hence pay the cost for translating, optimizing that query and storing its execution plan only once) and then call (execute) it multiple times with (potentially) different parameters (arguments), at ver low cost and it then is merely calling a pre-compiled function ...
This is a general idea, not MonetDB specific ...
No, but the problem of actually not being able to destroy them server side while staying connected /is/ MonetDB specific. I just opened a feature request for this, since this usage of PreparedStatements is actually fairly common.