Re: sub-select with aggregate

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Tomasz Myrta <jasiek(at)klaster(dot)net>
Cc: <pgsql-sql(at)postgresql(dot)org>
Subject: Re: sub-select with aggregate
Date: 2002-10-23 15:57:47
Message-ID: 20021023085544.S5843-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql


On Wed, 23 Oct 2002, Tomasz Myrta wrote:

> > On Wed, 23 Oct 2002, Tomasz Myrta wrote:
> >
> > > Uz.ytkownik Stephan Szabo napisa?:
> > Without group_id in the select list you couldn't do a where
> > group_id = <something> if the select was a view.
> I know - it was just example of query.
>
> > 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.
> I saw them. So should I wait for 7.3? Currently I have 7.2 and my work
> stopped because of this.

IIRC 7.2's explain doesn't show which clauses are on which plans (it'll
show that it's doing an index scan or whatever, but not what it's actually
looking for. The query probably optimizes similarly though. I'd suggest
trying it and seeing if it runs any better. I'm also assuming you have
an index on group_id to prevent the sequential scan of users.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Josh Berkus 2002-10-23 16:31:58 Re: Multiple Databases
Previous Message Stephan Szabo 2002-10-23 15:27:45 Re: sub-select with aggregate