Re: [GENERAL] Oddball data distribution giving me planner headaches

2011-12-03 Thread Harald Fuchs
Jeff Amiel writes: >> At the moment I think the only way to work around this is >> to denormalize >> your schema a bit. > And I feared as much. > It's biting me in other areas as well...this unusual distribution of > data...certain types of customers have completely different data patterns > t

Re: [GENERAL] Oddball data distribution giving me planner headaches

2011-12-02 Thread Jeff Amiel
--- On Fri, 12/2/11, Tom Lane wrote: > 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. The only caveat that I can think of

Re: [GENERAL] Oddball data distribution giving me planner headaches

2011-12-02 Thread Jeff Amiel
--- On Fri, 12/2/11, Tom Lane wrote: > 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. > I suspected as such. > At the mo

Re: [GENERAL] Oddball data distribution giving me planner headaches

2011-12-02 Thread Jeff Amiel
--- On Fri, 12/2/11, David Johnston wrote: > > > 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

Re: [GENERAL] Oddball data distribution giving me planner headaches

2011-12-02 Thread David Johnston
-Original Message- From: Jeff Amiel [mailto:becauseimj...@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 wrote: > F

Re: [GENERAL] Oddball data distribution giving me planner headaches

2011-12-02 Thread Tom Lane
Jeff Amiel 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 hav

Re: [GENERAL] Oddball data distribution giving me planner headaches

2011-12-02 Thread Jeff Amiel
--- On Fri, 12/2/11, David Johnston wrote: > From: David Johnston > - > 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 situati

Re: [GENERAL] Oddball data distribution giving me planner headaches

2011-12-02 Thread David Johnston
-Original Message- From: Jeff Amiel [mailto:becauseimj...@yahoo.com] Sent: Friday, December 02, 2011 4:15 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 wrote: > W

Re: [GENERAL] Oddball data distribution giving me planner headaches

2011-12-02 Thread Jeff Amiel
--- On Fri, 12/2/11, David Johnston wrote: > What happens if you disable, say, nested loops and/or index > scans? planner selects different join/indexing techniques (query is slower) but row estimates (bad) remain identical. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.o

Re: [GENERAL] Oddball data distribution giving me planner headaches

2011-12-02 Thread David Johnston
-Original Message- From: Jeff Amiel [mailto:becauseimj...@yahoo.com] Sent: Friday, December 02, 2011 3:52 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 wrote: > F

Re: [GENERAL] Oddball data distribution giving me planner headaches

2011-12-02 Thread Jeff Amiel
--- On Fri, 12/2/11, David Johnston wrote: > From: David Johnston > What kind of plan does the following give? > > EXPLAIN ANALYZE > SELECT * > FROM customer_rel p > JOIN customer c ON (p.parent_customer = c.customer_id) > WHERE c.customer_type = 'DISTRIBUTOR' Nearly identical output "Nested

Re: [GENERAL] Oddball data distribution giving me planner headaches

2011-12-02 Thread David Johnston
-Original Message- From: pgsql-general-ow...@postgresql.org [mailto:pgsql-general-ow...@postgresql.org] On Behalf Of Jeff Amiel Sent: Friday, December 02, 2011 3:20 PM To: pgsql-general@postgresql.org Subject: [GENERAL] Oddball data distribution giving me planner headaches explain

[GENERAL] Oddball data distribution giving me planner headaches

2011-12-02 Thread Jeff Amiel
Oddball data distribution giving me headaches. We have a distinct 'customer' table with customer_id, type and name/demographic information. Assume some 1 million rows in the customer table. We then have a customer 'relationship' table which simply contains 2 columns…designating parent and chil