Re: Functional dependency in GROUP BY through JOINs - Mailing list pgsql-hackers

From Kevin Grittner
Subject Re: Functional dependency in GROUP BY through JOINs
Date
Msg-id 20121206180009.142840@gmx.com
Whole thread Raw
In response to Functional dependency in GROUP BY through JOINs  ("David Rowley" <dgrowleyml@gmail.com>)
List pgsql-hackers
Tom Lane wrote:

> In the case being presented here, it's not apparent to me that
> there's any advantage to be had at all.

The OP reported a different plan which was twice as fast, although
showing EXPLAIN ANALYZE results for both would be nice confirmation
of that.

> You still need to aggregate over the rows joining to each
> uniquely-keyed row.

Yes.

> So how exactly are you going to "push down the GROUP BY", and
> where does the savings come from?

There are 1000000 million rows in bigsalestable that fall into 450
groups. The question is whether you look up related data in the
products table once per row or once per group. Apparently those
extra 999550 lookups take enough time to matter.

-Kevin



pgsql-hackers by date:

Previous
From: Simon Riggs
Date:
Subject: Re: Functional dependency in GROUP BY through JOINs
Next
From: Tom Lane
Date:
Subject: Re: Setting visibility map in VACUUM's second phase