Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id C4C871337C16 for ; Mon, 14 Mar 2011 15:51:02 -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 34753-01-10 for ; Mon, 14 Mar 2011 18:50:55 +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 5E2151337C3E for ; Mon, 14 Mar 2011 15:50:38 -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 p2EIoaBh027392; Mon, 14 Mar 2011 14:50:36 -0400 (EDT) To: Claudio Freire cc: pgsql-performance@postgresql.org Subject: Re: Performance regression from 8.3.7 to 9.0.3 In-reply-to: References: Comments: In-reply-to Claudio Freire message dated "Mon, 14 Mar 2011 12:54:56 -0300" Date: Mon, 14 Mar 2011 14:50:36 -0400 Message-ID: <27391.1300128636@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: 201103/146 X-Sequence-Number: 42825 Claudio Freire writes: > CREATE OR REPLACE VIEW member_all_tags_v AS > SELECT member_tags.member_id, member_tags.last_modification_date, > member_tags.polarity, member_tags.tag_id, 'mr' AS source > FROM member_tags > UNION ALL > SELECT member_profile_tags.member_id, > member_profile_tags.last_modification_date, member_profile_tags.polarity, > member_profile_tags.tag_id, 'profile' AS source > FROM member_profile_tags; Try casting those constants to text (or something) explicitly, ie 'mr'::text AS source etc. I forget at the moment why leaving them as unknown literals interferes with optimization, but it does. regards, tom lane