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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, Dec 18, 2011 at 16:52, Roxanne Reid-Bennett <rox@xxxxxxxxxxx> 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

-- 
Sent via pgsql-performance mailing list (pgsql-performance@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-performance


[Postgresql General]     [Postgresql PHP]     [PHP Users]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Yosemite]

  Powered by Linux