Re: Oddball data distribution giving me planner headaches - Mailing list pgsql-general

From David Johnston
Subject Re: Oddball data distribution giving me planner headaches
Date
Msg-id 039001ccb13f$eb52cd30$c1f86790$@yahoo.com
Whole thread Raw
In response to Re: Oddball data distribution giving me planner headaches  (Jeff Amiel <becauseimjeff@yahoo.com>)
Responses Re: Oddball data distribution giving me planner headaches
List pgsql-general
-----Original Message-----
From: Jeff Amiel [mailto:becauseimjeff@yahoo.com]
Sent: Friday, December 02, 2011 5:07 PM
To: pgsql-general@postgresql.org; David Johnston
Subject: RE: [GENERAL] Oddball data distribution giving me planner headaches



--- On Fri, 12/2/11, David Johnston <polobo@yahoo.com> wrote:

> From: David Johnston <polobo@yahoo.com>

> ---------------------------------------------------------
> 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.



pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Oddball data distribution giving me planner headaches
Next
From: Jeff Amiel
Date:
Subject: Re: Oddball data distribution giving me planner headaches