Re: Functional dependency in GROUP BY through JOINs

From: "Kevin Grittner" <kgrittn(at)mail(dot)com>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>,"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 18:00:08
Message-ID: 20121206180009.142840@gmx.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2012-12-06 18:01:33 Re: Setting visibility map in VACUUM's second phase
Previous Message Simon Riggs 2012-12-06 17:57:33 Re: Functional dependency in GROUP BY through JOINs