Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YBt8I-0001fi-Fy for pgsql-bugs@arkaria.postgresql.org; Thu, 15 Jan 2015 22:43:18 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YBt8H-0005k6-Ni for pgsql-bugs@arkaria.postgresql.org; Thu, 15 Jan 2015 22:43:17 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YBt8G-0005jz-N2 for pgsql-bugs@postgresql.org; Thu, 15 Jan 2015 22:43:16 +0000 Received: from mx-out.zmailcloud.com ([192.198.85.98] helo=mx-out-1.zmailcloud.com) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YBt88-00064a-Qb for pgsql-bugs@postgresql.org; Thu, 15 Jan 2015 22:43:14 +0000 Received: from smtp.01.com (smtp.01.com [10.10.0.43]) by mx-out-1.zmailcloud.com (Postfix) with ESMTP id 40873564BF0 for ; Thu, 15 Jan 2015 16:43:07 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by smtp-out-1.01.com (Postfix) with ESMTP id 3A6C3A02F6 for ; Thu, 15 Jan 2015 16:43:07 -0600 (CST) X-Virus-Scanned: amavisd-new at smtp-out-1.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-1.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yEg6K0VYs0rk for ; Thu, 15 Jan 2015 16:43:07 -0600 (CST) Received: from smtp.01.com (localhost [127.0.0.1]) by smtp-out-1.01.com (Postfix) with ESMTP id 13249A03F5 for ; Thu, 15 Jan 2015 16:43:07 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by smtp-out-1.01.com (Postfix) with ESMTP id E99CCA032B for ; Thu, 15 Jan 2015 16:43:06 -0600 (CST) X-Virus-Scanned: amavisd-new at smtp-out-1.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-1.01.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id z6_2Za2R16ft for ; Thu, 15 Jan 2015 16:43:06 -0600 (CST) Received: from [172.24.244.13] (wireless-nat-23-linuxconf2015.auckland.ac.nz [130.216.30.134]) by smtp-out-1.01.com (Postfix) with ESMTPSA id 65ACCA02F6 for ; Thu, 15 Jan 2015 16:43:06 -0600 (CST) Message-ID: <54B84278.2000800@agliodbs.com> Date: Fri, 16 Jan 2015 11:43:04 +1300 From: Josh Berkus Organization: PostgreSQL Experts Inc. User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.3.0 MIME-Version: 1.0 To: pgsql-bugs@postgresql.org Subject: Partial indexes on VARCHAR get double converted from text Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org create table stately ( id int, filename varchar(255), state varchar(255) ); create index on stately(state) where state in ( 'pending', 'waiting', 'done' ); \d stately Table "public.stately" Column | Type | Modifiers ----------+------------------------+----------- id | integer | filename | character varying(255) | state | character varying(255) | Indexes: "stately_state_idx" btree (state) WHERE state::text = ANY (ARRAY['pending'::character varying, 'waiting'::character varying, 'done'::character varying]::text[]) There is no combination of typecasting which will prevent this outcome. I've tried. Further, it seems to me from testing that this double type conversion affects the planner's costing of the index, causing it to not want to use the index. -- Josh Berkus PostgreSQL Experts Inc. http://pgexperts.com -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs