Received: from localhost (maia-5.hub.org [200.46.204.182]) by postgresql.org (Postfix) with ESMTP id 2309E9FB4EE for ; Thu, 12 Jul 2007 09:51:54 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.182]) (amavisd-maia, port 10024) with ESMTP id 11399-06 for ; Thu, 12 Jul 2007 09:51:42 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by postgresql.org (Postfix) with ESMTP id 583389FB458 for ; Thu, 12 Jul 2007 09:51:49 -0300 (ADT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.8/8.13.8) with ESMTP id l6CCpcpc042691 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 12 Jul 2007 06:51:41 -0600 (MDT) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.14.1/8.14.1) with ESMTP id l6CCpbxb051604; Thu, 12 Jul 2007 06:51:37 -0600 (MDT) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.14.1/8.14.1/Submit) id l6CCpbNZ051601; Thu, 12 Jul 2007 06:51:37 -0600 (MDT) (envelope-from mfuhr) Date: Thu, 12 Jul 2007 06:51:36 -0600 From: Michael Fuhr To: Heikki Linnakangas Cc: Marcin =?utf-8?Q?St=C4=99pnicki?= , pgsql-performance@postgresql.org Subject: Re: one column from huge view Message-ID: <20070712125136.GA37198@winnie.fuhr.org> References: <4695EB62.7060307@enterprisedb.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <4695EB62.7060307@enterprisedb.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200707/140 X-Sequence-Number: 25824 On Thu, Jul 12, 2007 at 09:50:42AM +0100, Heikki Linnakangas wrote: > Marcin Stępnicki wrote: > >Let's say I've got a view with 100 columns and 1mln rows; some of them are > >calculated "on the fly". For some reason I want only one column from > >this view: > > > >select col1 from huge_view; > > > >Now, does PostgreSQL skip all the calculations from other columns and > >executes this query faster then select * from huge_view? > > In simple cases, yes. But for example, if you have a LEFT OUTER JOIN in > the view, the join is performed even if your query doesn't return any > columns from the outer relation. Also, if the calculation contains > immutable functions, it's not skipped. Don't you mean "if the calculation contains VOLATILE functions, it's not skipped"? -- Michael Fuhr