Feature request: smarter use of conditional indexes

From: John Siracusa <siracusa(at)mindspring(dot)com>
To: Postgres Performance <pgsql-performance(at)postgresql(dot)org>
Subject: Feature request: smarter use of conditional indexes
Date: 2004-03-03 19:56:06
Message-ID: BC6BA286.833F4%siracusa@mindspring.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Given an index like this:

CREATE UNIQUE INDEX i1 ON t1 (c1) WHERE c1 IS NOT NULL;

and a query like this:

SELECT * FROM t1 WHERE c1 = 123;

I'd like the planner to be smart enough to use an index scan using i1. Yes,
I can change the query to this:

SELECT * FROM t1 WHERE c1 = 123 AND c1 IS NOT NULL;

In which case the index will be used, but I shouldn't have to. More
practically, since a lot of my SQL is auto-generated, it's difficult to make
this query change just in the cases where I need it. And I'm loathe to
change every "column = value" pair in my auto-generated SQL into a double
pair of "(column = value and column is not null)" It's redundant and looks
pretty silly, IMO.

Thanks for you consideration :)

-John

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Vivek Khera 2004-03-03 20:28:53 Re: Bulk INSERT performance in 7.4.1
Previous Message Josh Berkus 2004-03-03 19:09:23 Re: Scaling further up