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

From Tom Lane
Subject Re: Oddball data distribution giving me planner headaches
Date
Msg-id 25344.1322863743@sss.pgh.pa.us
Whole thread Raw
In response to Oddball data distribution giving me planner headaches  (Jeff Amiel <becauseimjeff@yahoo.com>)
Responses Re: Oddball data distribution giving me planner headaches
Re: Oddball data distribution giving me planner headaches
List pgsql-general
Jeff Amiel <becauseimjeff@yahoo.com> writes:
> Oddball data distribution giving me headaches.
> [ 'distributor' customers have many more child customers than average ]
> Does this oddball data distribution doom me to poor planning forever?

The only real fix for that will require cross-column statistics, which
we don't have yet --- without such, there's no way for the planner to
know that distributors have an atypical number of child customers.

At the moment I think the only way to work around this is to denormalize
your schema a bit.  For instance, if you were to include the parent
customer_type directly into the customer_rel table, that would not only
save one join in this query but it would expose the stats the planner
needs to realize that it's going to get a lot of matches.  If you don't
like that particular solution there are probably other ways to get the
same result, but they're all going to require schema changes.

            regards, tom lane

pgsql-general by date:

Previous
From: Jeff Amiel
Date:
Subject: Re: Oddball data distribution giving me planner headaches
Next
From: "David Johnston"
Date:
Subject: Re: Oddball data distribution giving me planner headaches