Re: Oddball data distribution giving me planner headaches

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Jeff Amiel <becauseimjeff(at)yahoo(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Oddball data distribution giving me planner headaches
Date: 2011-12-02 22:09:03
Message-ID: 25344.1322863743@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Jeff Amiel <becauseimjeff(at)yahoo(dot)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

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message David Johnston 2011-12-02 22:15:36 Re: Oddball data distribution giving me planner headaches
Previous Message Jeff Amiel 2011-12-02 22:06:34 Re: Oddball data distribution giving me planner headaches