Re: Searching for the cause of a bad plan - Mailing list pgsql-performance

From Simon Riggs
Subject Re: Searching for the cause of a bad plan
Date
Msg-id 1190906677.4194.78.camel@ebony.site
Whole thread Raw
In response to Re: Searching for the cause of a bad plan  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-performance
On Thu, 2007-09-27 at 10:40 -0400, Tom Lane wrote:

> And yet there's another trap here: if the parameter you passed in
> chanced to be one of the very common values, a plan that was optimized
> for a small number of matches would perform terribly.

I wonder could we move prepare_threshold onto the server? (from JDBC).

When we prepare a statement, we record the current setting of the
prepare_threshold parameter into the plan for that statement. Valid
settings are -1, 0 or more.
If the setting is -1 then we always re-plan the statement.
If the setting is 0 then we plan the statement generically.
If the setting is > 0 then we plan the statement according to the
specific parameter value and then decrement the prepare count, so
eventually the executions will hit 0 (above).

That would also simplify JDBC and allow the functionality from other
clients, as well as from within PLs.

We could also force the plan to be -1 when the planning involves
something that would force it to be a one-time plan, e.g. constraint
exclusion. (So we could then get rid of that parameter).

--
  Simon Riggs
  2ndQuadrant  http://www.2ndQuadrant.com


pgsql-performance by date:

Previous
From: Csaba Nagy
Date:
Subject: Re: Searching for the cause of a bad plan
Next
From: Kevin Kempter
Date:
Subject: Tuning for warm standby