Skip site navigation (1) Skip section navigation (2)

Re: will the planner ever use an index when the condition is <> ?

From: Marti Raudsepp <marti(at)juffo(dot)org>
To: Roxanne Reid-Bennett <rox(at)tara-lu(dot)com>
Cc: pgsql-performance(at)postgresql(dot)org
Subject: Re: will the planner ever use an index when the condition is <> ?
Date: 2011-12-18 20:11:28
Message-ID: CABRT9RC7UHCgqhcOi9W5U3wzKpv3H9FWkdZpP0vuKFxbamhb3A@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-performance
On Sun, Dec 18, 2011 at 16:52, Roxanne Reid-Bennett <rox(at)tara-lu(dot)com> wrote:
> Is there an index type that can check "not equal"?
> This specific column has a limited number of possible values - it is
> essentially an enumerated list.

Instead of writing WHERE foo<>3 you could rewrite it as WHERE foo IN
(1,2,4,...) or WHERE foo < 3 OR foo > 3. Both of these are indexable
queries, but obviously the planner may choose not to use index scan if
it's not worth it.

Regards,
Marti

In response to

pgsql-performance by date

Next:From: Roxanne Reid-BennettDate: 2011-12-18 20:18:49
Subject: Re: will the planner ever use an index when the condition is <> ?
Previous:From: Tom LaneDate: 2011-12-18 18:31:26
Subject: Re: will the planner ever use an index when the condition is <> ?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group