pg.ddx.io  pgsql-performance@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: CoL <col@mportal.hu>
To: pgsql-performance@postgresql.org
Subject: Re: Feature request: smarter use of conditional indexes
Date: Thu, 04 Mar 2004 00:37:46 +0100
Message-ID: <c25q4g$1ei7$1@news.hub.org> (raw)
In-Reply-To: <BC6BA286.833F4%siracusa@mindspring.com>
References: <BC6BA286.833F4%siracusa@mindspring.com>

hi,

John Siracusa wrote, On 3/3/2004 20:56:

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

how about: CREATE UNIQUE INDEX i1 ON t1 (c1);
WHERE c1 IS NOT NULL in this case what is the point of doing this?
You do not need this condition.

C.



view thread (11+ messages)  latest in thread

Message-ID: <c25q4g$1ei7$1@news.hub.org>
Permalink:  ../c25q4g$1ei7$1@news.hub.org/
Also on:    postgresql.org/message-id/c25q4g$1ei7$1@news.hub.org

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-performance@postgresql.org
  Cc: col@mportal.hu
  Subject: Re: Feature request: smarter use of conditional indexes
  In-Reply-To: <c25q4g$1ei7$1@news.hub.org>

* 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