Received: from localhost (unknown [200.46.204.184]) by developer.postgresql.org (Postfix) with ESMTP id 58E7A2E0038 for ; Sat, 5 Apr 2008 01:20:48 -0300 (ADT) Received: from developer.postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-maia, port 10024) with ESMTP id 75983-10 for ; Sat, 5 Apr 2008 01:20:27 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.5 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by developer.postgresql.org (Postfix) with ESMTP id 9A69B2E002F for ; Sat, 5 Apr 2008 01:20:44 -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 m354Khnr028881; Sat, 5 Apr 2008 00:20:43 -0400 (EDT) To: "Matt Klinker" cc: pgsql-performance@postgresql.org Subject: Re: Query plan excluding index on view In-reply-to: <3bda20f60804040726m15e1b9caqad3883cba960bab0@mail.gmail.com> References: <3bda20f60804031631j177b42e2u82b5033fd23c2293@mail.gmail.com> <28177.1207266621@sss.pgh.pa.us> <3bda20f60804031654q7991de08m1254964511632acf@mail.gmail.com> <29828.1207271948@sss.pgh.pa.us> <3bda20f60804032158u4f6765e3t8b0debad3e7f5ceb@mail.gmail.com> <4767.1207288167@sss.pgh.pa.us> <3bda20f60804040726m15e1b9caqad3883cba960bab0@mail.gmail.com> Comments: In-reply-to "Matt Klinker" message dated "Fri, 04 Apr 2008 08:26:50 -0600" Date: Sat, 05 Apr 2008 00:20:43 -0400 Message-ID: <28880.1207369243@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200804/49 X-Sequence-Number: 29542 "Matt Klinker" writes: > --Joined View: > CREATE OR REPLACE VIEW directory_listing AS > SELECT school.id, school.name, school.description, 119075291 AS > listing_type_fid > FROM school > UNION ALL > SELECT company.id, company.name, company.description, 119074833 AS > listing_type_fid > FROM company; Ah, there's the problem :-(. Can you get rid of the constants here? The planner's currently not smart about UNION ALL subqueries unless their SELECT lists contain just simple column references. (Yes, fixing that is on the todo list, but don't hold your breath... it'll be 8.4 material at the earliest.) regards, tom lane