pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: pgsql-bugs@postgresql.org
Subject: Partial indexes on VARCHAR get double converted from text
Date: Fri, 16 Jan 2015 11:43:04 +1300
Message-ID: <54B84278.2000800@agliodbs.com> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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



view thread (3+ messages)  latest in thread

Message-ID: <54B84278.2000800@agliodbs.com>
Permalink:  ../54B84278.2000800@agliodbs.com/
Also on:    postgresql.org/message-id/54B84278.2000800@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: josh@agliodbs.com
  Subject: Re: Partial indexes on VARCHAR get double converted from text
  In-Reply-To: <54B84278.2000800@agliodbs.com>
  References: <54B84278.2000800@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox