Re: Partial indexes on VARCHAR get double converted from text

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Josh Berkus <josh(at)agliodbs(dot)com>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Partial indexes on VARCHAR get double converted from text
Date: 2015-01-16 01:52:18
Message-ID: 4537.1421373138@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

Josh Berkus <josh(at)agliodbs(dot)com> 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.

> 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.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message cadabreenow 2015-01-16 02:10:19 BUG #12560: can not run alot of databases
Previous Message Josh Berkus 2015-01-15 22:43:04 Partial indexes on VARCHAR get double converted from text