-----Original Message----- From: Jeff Amiel [mailto:becauseimjeff@xxxxxxxxx] Sent: Friday, December 02, 2011 5:07 PM To: pgsql-general@xxxxxxxxxxxxxx; David Johnston Subject: RE: Oddball data distribution giving me planner headaches --- On Fri, 12/2/11, David Johnston <polobo@xxxxxxxxx> wrote: > From: David Johnston <polobo@xxxxxxxxx> > --------------------------------------------------------- > My, possibly naïve, observation: > > So aside from the fact the estimates seem to be off the planner has > still chosen the most effective plan? In that situation no matter how > accurate you get the statistics you will not gain any performance > because the planner will never choose a different plan. > Thanks..... I'm not interested in optimizing this query.....it's fast and efficient. However, the planner thinks that it is going to return a million rows when it is only going to return one thousand. When this query is used as an element of a BIGGER query, that causes me all sorts of planner issues.... That's the problem I am trying to solve...why the planner is 3 orders of magnitude off in row estimation. -------------------------------------------------------- Can you wrap the query into an SQL or PL/pgSQL function so that, at least, then planner will not be able to see the embedded plan info in the outer queries? You use-case may allow you to create one or more VIEWs wrapping the function call with pre-determined parameters so that you do not lose the ability to write simple select queries without the need for explicit function calls. No idea how that would impact the planner for the other queries but maybe worth a try while waiting for someone more knowledgeable than myself to respond. David J. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general