Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id BB27D650452 for ; Tue, 11 Nov 2008 22:34:57 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 27203-03 for ; Tue, 11 Nov 2008 22:34:54 -0400 (AST) 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 F386D64FC2D for ; Tue, 11 Nov 2008 22:34:54 -0400 (AST) 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 mAC2YoSc021847; Tue, 11 Nov 2008 21:34:50 -0500 (EST) To: "Jim 'Decibel!' Nasby" cc: Richard Huxton , postgresql performance list Subject: Re: Oddity with view (now with test case) In-reply-to: <1F9C31B6-6F89-4BD9-8799-2DA4DF254A48@cashnetusa.com> References: <3CF0CFC1-FDBA-4A61-ACAA-6AF556C4C6F4@cashnetusa.com> <3128.1226322412@sss.pgh.pa.us> <7B598355-07C0-450A-9914-B5979F48A5B3@cashnetusa.com> <49187BA7.8020403@archonet.com> <1E5A4D7D-3B95-440B-A377-B6B9F8768F7A@cashnetusa.com> <12776.1226345499@sss.pgh.pa.us> <9474.1226373609@sss.pgh.pa.us> <03B6DDDD-C1E9-4897-864B-46892FCBE379@cashnetusa.com> <10664.1226430946@sss.pgh.pa.us> <1F9C31B6-6F89-4BD9-8799-2DA4DF254A48@cashnetusa.com> Comments: In-reply-to "Jim 'Decibel!' Nasby" message dated "Tue, 11 Nov 2008 16:42:57 -0600" Date: Tue, 11 Nov 2008 21:34:50 -0500 Message-ID: <21846.1226457290@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200811/85 X-Sequence-Number: 31816 "Jim 'Decibel!' Nasby" writes: > So here's something odd... in both 8.3 and HEAD from a while ago it > gives a better plan for SELECT * than for SELECT count(*): The short answer is that the Subquery Scan nodes can be dropped out when they are no-ops, which is to say producing the same set of columns their input produces (and not testing any filter conditions, but that's not relevant here). SELECT count(*) doesn't want to know about any columns so the output of the UNION arm doesn't match ... regards, tom lane