Received: from maia.hub.org (maia-2.hub.org [200.46.204.251]) by mail.postgresql.org (Postfix) with ESMTP id 304C36332B3 for ; Fri, 30 Jul 2010 12:02:22 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.251]) (amavisd-maia, port 10024) with ESMTP id 38037-09 for ; Fri, 30 Jul 2010 15:02:15 +0000 (UTC) X-Greylist: delayed 00:06:39.848011 by SQLgrey-1.7.6 Received: from alexander.swishmail.com (alexander.swishmail.com [208.72.56.31]) by mail.postgresql.org (Postfix) with ESMTP id C0ED96326C0 for ; Fri, 30 Jul 2010 12:02:14 -0300 (ADT) Received: (qmail 67797 invoked by uid 89); 30 Jul 2010 14:55:34 -0000 Received: from unknown (HELO ?127.0.0.1?) (eric.schwarzenbach@wrycan.com@209.6.93.90) by alexander.swishmail.com with ESMTPA; 30 Jul 2010 14:55:34 -0000 Message-ID: <4C52E7E4.4020204@blackbrook.org> Date: Fri, 30 Jul 2010 10:55:32 -0400 From: Eric Schwarzenbach User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.23) Gecko/20090812 Thunderbird/2.0.0.23 Mnenhy/0.7.5.0 MIME-Version: 1.0 To: pgsql-performance@postgresql.org Subject: view columns and performance Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-0.001 tagged_above=-10 required=5 tests=BAYES_20=-0.001, RCVD_IN_DNSWL_NONE=-0.0001 X-Spam-Level: X-Archive-Number: 201007/451 X-Sequence-Number: 39840 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. In other words supposed I define a view something like CREATE view MyView AS SELECT a,b, c, d, e, f, g FROM (several tables joined together) Assume for the sake of simplicity there are no aggregates or such, we're just joining tables, and getting a bunch of columns back each of the various tables. I then then perform a query something like SELECT v.a, x.h, y.i FROM MyView as v JOIN otherTable as x on (x.m = v.a) JOIN yetAnotherTable as y on (y.n=v.a) Does all the extra clutter of b,c,d,e,f in MyView affect the performance of the query by taking up extra space in memory during the joins or is the optimizer smart enough to realize that they aren't needed and evoke the query as if MyView were really defined as CREATE view MyView AS SELECT a FROM (several tables joined together)? Thanks, Eric