Re: sub-select with aggregate - Mailing list pgsql-sql

From Stephan Szabo
Subject Re: sub-select with aggregate
Date
Msg-id 20021023082355.G5481-100000@megazone23.bigpanda.com
Whole thread Raw
In response to Re: sub-select with aggregate  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Responses Re: sub-select with aggregate
List pgsql-sql
On Wed, 23 Oct 2002, Stephan Szabo wrote:

> Did you see the other two queries I gave?  On 7.3, both of those queries
> appear (according to explain output) to do the limiting of group_id
> inside the subquery rather than doing the subquery with all rows.
> The explanation above was why I believe it was different from your
> original query.

Replying to myself with a clarification.

The other forms only move the filtering clauses around.  There's still
only a filter on the outer group_id equaling the inner group_id and
a filter on group_id=3.  It's just a question of whether it's:

Scan users in subselect from group_id=3, group and aggregate themand join with users on subselect's group_id =
users.group_id

or

Scan users for group_id=3, scan users in subselect, group andaggregate them and join these two on
subselect'sgroup_id=users.group_id.

The latter is effectively what your original query gave, the former
appears to be what my two queries from a couple of mails ago gives.




pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: sub-select with aggregate
Next
From: "Tomasz Myrta"
Date:
Subject: Re: sub-select with aggregate