Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 26777475AAC for ; Wed, 23 Oct 2002 11:57:48 -0400 (EDT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [63.150.15.178]) by postgresql.org (Postfix) with ESMTP id 62FDF4764EF for ; Wed, 23 Oct 2002 11:57:43 -0400 (EDT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 15B35D613; Wed, 23 Oct 2002 08:57:47 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id A9B1D5C03; Wed, 23 Oct 2002 08:57:47 -0700 (PDT) Date: Wed, 23 Oct 2002 08:57:47 -0700 (PDT) From: Stephan Szabo To: Tomasz Myrta Cc: Subject: Re: sub-select with aggregate In-Reply-To: <20021023174445.M37904@klaster.net> Message-ID: <20021023085544.S5843-100000@megazone23.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/301 X-Sequence-Number: 10018 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 = 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.