Re: Postgres refusing to use >1 core

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: sthomas(at)peak6(dot)com
Cc: Josh Berkus <josh(at)agliodbs(dot)com>, pgsql-performance(at)postgresql(dot)org
Subject: Re: Postgres refusing to use >1 core
Date: 2011-05-12 16:07:54
Message-ID: 18068.1305216474@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Shaun Thomas <sthomas(at)peak6(dot)com> writes:
> On 05/12/2011 09:51 AM, Tom Lane wrote:
>> It does. I was a bit surprised that Shaun apparently got a plan that
>> didn't include a materialize step, because when I test a similar query
>> here, I get:

> Remember when I said "old version" that prevented us from using CTEs?
> We're still on 8.2 (basically, we're waiting for EnterpriseDB 9.0).
> It's basically calculating the group aggregation wrong, but is that
> enough to trigger it to go nuts?

Hmm. As you say, the mistake it's making is a drastic underestimate of
the number of groups in the subquery, leading to a bad choice of join
method. I find it odd that replacing the subquery with a temp table
helps, though, because (unless you stuck in an ANALYZE you didn't
mention) it would have no stats at all about the number of groups in the
temp table. Maybe the default guess just happens to produce the more
desirable plan.

regards, tom lane

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Shaun Thomas 2011-05-12 16:11:21 Re: Postgres refusing to use >1 core
Previous Message Prodan, Andrei 2011-05-12 15:53:38 Re: 'Interesting' prepared statement slowdown on large table join