← Back to team overview

launchpad-dev team mailing list archive

Re: Performance question

 

On 2010-09-21 09:23, Stuart Bishop wrote:

Few people use prepared statements with PostgreSQL as they are rarely
a win. With a prepared statement, a query plan must be chosen without
paying attention to the arguments and this will often perform much
worse than a query plan that is chosen when the arguments are known -

Exactly: prepared statements are a way to win a few milliseconds, but also a way to lose seconds or even minutes.

There have even been calls in the postgres team for not preparing them at all, and re-planning for every execution instead. I discussed fixes with the core postgres team, but the subsequent bikeshedding on the mailing list took up all the time I had allocated. It's something I may return to if I find time (in December or later).


different query plans. Also in the modern world with modern CPUs the
time spent in the planner is usually insignificant.

Even when it's not, we'd probably ask "why are we executing this query so often?" before we'd ask "can we shave some planning time off this query?"

(Batch inserts can be difficult, but those would gain much more from using the COPY command which pumps any number of rows into or out of a table in one go).


Jeroen



Follow ups

References