Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id 773BA9FB280 for ; Tue, 10 Apr 2007 14:03:20 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-maia, port 10024) with ESMTP id 26263-02 for ; Tue, 10 Apr 2007 14:03:17 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 8A2699FA0DD for ; Tue, 10 Apr 2007 14:03:08 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id l3AH366Z027417; Tue, 10 Apr 2007 13:03:06 -0400 (EDT) To: "Merlin Moncure" cc: "PostgreSQL Performance" Subject: Re: join to view over custom aggregate seems like it should be faster In-reply-to: References: <10651.1176152866@sss.pgh.pa.us> Comments: In-reply-to "Merlin Moncure" message dated "Tue, 10 Apr 2007 08:59:23 -0400" Date: Tue, 10 Apr 2007 13:03:06 -0400 Message-ID: <27416.1176224586@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200704/233 X-Sequence-Number: 24110 "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. regards, tom lane