Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YBxWm-0002OU-6I for pgsql-bugs@arkaria.postgresql.org; Fri, 16 Jan 2015 03:24:52 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YBxWl-0002XT-Ew for pgsql-bugs@arkaria.postgresql.org; Fri, 16 Jan 2015 03:24:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YBxWk-0002XN-QP for pgsql-bugs@postgresql.org; Fri, 16 Jan 2015 03:24:50 +0000 Received: from mx-out.zmailcloud.com ([192.198.85.98] helo=mx-out-1.zmailcloud.com) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YBxWg-0002lu-P3 for pgsql-bugs@postgresql.org; Fri, 16 Jan 2015 03:24:49 +0000 Received: from smtp.01.com (smtp.01.com [10.10.0.43]) by mx-out-1.zmailcloud.com (Postfix) with ESMTP id 9B0D2564CB7; Thu, 15 Jan 2015 21:24:44 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by smtp-out-2.01.com (Postfix) with ESMTP id 880C560286; Thu, 15 Jan 2015 21:24:44 -0600 (CST) X-Virus-Scanned: amavisd-new at smtp-out-2.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-2.01.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id BJmmvfkkM7w3; Thu, 15 Jan 2015 21:24:44 -0600 (CST) Received: from smtp.01.com (localhost [127.0.0.1]) by smtp-out-2.01.com (Postfix) with ESMTP id 694E260288; Thu, 15 Jan 2015 21:24:44 -0600 (CST) Received: from localhost (localhost [127.0.0.1]) by smtp-out-2.01.com (Postfix) with ESMTP id 4A40C60287; Thu, 15 Jan 2015 21:24:44 -0600 (CST) X-Virus-Scanned: amavisd-new at smtp-out-2.01.com Received: from smtp.01.com ([127.0.0.1]) by localhost (smtp-out-2.01.com [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id VTZwlfktiWR8; Thu, 15 Jan 2015 21:24:44 -0600 (CST) Received: from [172.24.244.13] (wireless-nat-23-linuxconf2015.auckland.ac.nz [130.216.30.134]) by smtp-out-2.01.com (Postfix) with ESMTPSA id 1481660286; Thu, 15 Jan 2015 21:24:42 -0600 (CST) Message-ID: <54B88478.6060207@agliodbs.com> Date: Fri, 16 Jan 2015 16:24:40 +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: Tom Lane CC: pgsql-bugs@postgresql.org Subject: Re: Partial indexes on VARCHAR get double converted from text References: <54B84278.2000800@agliodbs.com> <4537.1421373138@sss.pgh.pa.us> In-Reply-To: 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 On 01/16/2015 02:52 PM, Tom Lane wrote: > Josh Berkus writes: >> 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[]) > > I see no bug here. It's doing what's expected. Why have the multiple conversions to and from TEXT? It's certainly visually confusing to users. > >> 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. > > That's not a bug report, that's just unsupported speculation. Moreover, > if there were any such effect, it would cause the planner to reject the > index entirely, not just penalize it cost-wise. I thought I had a test case which showed different costing for varchar vs. text, but the results are more confusing than that. Will delve further. -- 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