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

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

 



Roxanne Reid-Bennett <rox@xxxxxxxxxxx> writes:
> On 12/17/2011 11:24 AM, Filip RembiaÅ?kowski wrote:
>> Normally there is no chance it could work,
>> because (a) the planner does not know all possible values of a column,
>> and (b) btree indexes cannot search on "not equal" operator.

> Is there an index type that can check "not equal"?

There is not.  It's not so much that it's logically impossible as that
it doesn't seem worth the trouble to implement and maintain, because
most of the time a query like "where x <> constant" is going to fetch
most of the table, and so it would be better done as a seqscan anyway.

If you have a specific case where that's not true, you might consider
a partial index (CREATE INDEX ... WHERE x <> constant).  But the details
of that would depend a lot on the queries you're concerned about.

			regards, tom lane

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