Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id 75344634007 for ; Fri, 30 Jul 2010 12:11:48 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 54881-02 for ; Fri, 30 Jul 2010 15:11:41 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id D28DB634669 for ; Fri, 30 Jul 2010 12:11:06 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o6UFB2ja006515; Fri, 30 Jul 2010 11:11:03 -0400 (EDT) To: Eric Schwarzenbach cc: pgsql-performance@postgresql.org Subject: Re: view columns and performance In-reply-to: <4C52E7E4.4020204@blackbrook.org> References: <4C52E7E4.4020204@blackbrook.org> Comments: In-reply-to Eric Schwarzenbach message dated "Fri, 30 Jul 2010 10:55:32 -0400" Date: Fri, 30 Jul 2010 11:11:02 -0400 Message-ID: <6514.1280502662@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201007/452 X-Sequence-Number: 39841 Eric Schwarzenbach writes: > I'm wondering whether columns, in the select list of a view that is used > in a join, which are not used either as join criteria or in the select > list of the overall query, effect the performance of the query. If the view gets "flattened" into the calling query then unreferenced columns will be optimized away, otherwise probably not. You haven't given enough details about your intended view definition to be sure whether it can be optimized, but if it's just a join it's fine. regards, tom lane