Re: Functional dependency in GROUP BY through JOINs

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Simon Riggs <simon(at)2ndQuadrant(dot)com>
Cc: David Rowley <dgrowleyml(at)gmail(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Functional dependency in GROUP BY through JOINs
Date: 2012-12-06 17:21:32
Message-ID: 5474.1354814492@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Simon Riggs <simon(at)2ndQuadrant(dot)com> writes:
> On 5 December 2012 23:37, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
>> Though this plan might not be quite as optimal as it could be as it performs
>> the grouping after the join.

> PostgreSQL always calculates aggregation as the last step.

> It's a well known optimisation to push-down GROUP BY clauses to the
> lowest level, but we don't do that, yet.

> You're right that it can make a massive difference to many queries.

In the case being presented here, it's not apparent to me that there's
any advantage to be had at all. You still need to aggregate over the
rows joining to each uniquely-keyed row. So how exactly are you going
to "push down the GROUP BY", and where does the savings come from?

regards, tom lane

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jeff Janes 2012-12-06 17:27:48 Re: Slow query: bitmap scan troubles
Previous Message Stephen Frost 2012-12-06 17:02:53 Re: Commits 8de72b and 5457a1 (COPY FREEZE)