Received: from localhost (maia-4.hub.org [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 4EFA39FA392 for ; Tue, 10 Apr 2007 14:53:19 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 67854-03-2 for ; Tue, 10 Apr 2007 14:53:05 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from wx-out-0506.google.com (wx-out-0506.google.com [66.249.82.231]) by postgresql.org (Postfix) with ESMTP id B51579FA339 for ; Tue, 10 Apr 2007 14:53:05 -0300 (ADT) Received: by wx-out-0506.google.com with SMTP id i28so1781854wxd for ; Tue, 10 Apr 2007 10:53:05 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=AZCiWb9hiYczHVMKRUAM90qAbZWNVX0OhjSDJXMO0EE/FmjjqsN8PAZivPRscp3MGM285LufMtjGbnE7itZ7NETNF7hw9iNDB5n13OfOI7/fVvRzUuMc4tRw5Kyt1B2qb5CJNZJ9KWdSiDXfohpdahRYwesc2RJ0jUQq9csd0gQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=CYaxWBmv5nhzMq3spFUPdRKuIGp+QV5NSZJUPDAlPKQaNljiIz6UrXuFtvQoxyyABnheDc6sOhSEIOacIE35d7CklWvwBJA7vCibkXUbA7mJq4t2X/+af/itH+EhdwCgOr6lwhE8JWE5JhtsGvg9ff9bme7sTOONNPjbUcSkLYM= Received: by 10.78.193.19 with SMTP id q19mr1127429huf.1176227583126; Tue, 10 Apr 2007 10:53:03 -0700 (PDT) Received: by 10.78.35.18 with HTTP; Tue, 10 Apr 2007 10:53:02 -0700 (PDT) Message-ID: Date: Tue, 10 Apr 2007 13:53:02 -0400 From: "Merlin Moncure" To: "Tom Lane" Subject: Re: join to view over custom aggregate seems like it should be faster Cc: "PostgreSQL Performance" In-Reply-To: <27416.1176224586@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <10651.1176152866@sss.pgh.pa.us> <27416.1176224586@sss.pgh.pa.us> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/234 X-Sequence-Number: 24111 On 4/10/07, Tom Lane wrote: > "Merlin Moncure" writes: > > For some reason, I can't get the index to be used on the table sitting > > under a view during a join, even though it should be, or at least it > > seems.... > > Nope, that's not going to work, because the aggregate keeps the subquery > from being flattened into the upper query, which is what would have to > happen for a nestloop-with-inner-indexscan join to be considered. > AFAICS you've got to structure it so that the aggregation happens above > the join. right, i see that it's actually the 'group by' that does it: select a, b from foo join (select a, b from bar group by a,b) q using (a,b); is enough to keep it from using the index on a,b from bar. thats too bad... merlin