Re: will the planner ever use an index when the condition is <> ?
От | Tom Lane |
---|---|
Тема | Re: will the planner ever use an index when the condition is <> ? |
Дата | |
Msg-id | 3088.1324233086@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | Re: will the planner ever use an index when the condition is <> ? (Roxanne Reid-Bennett <rox@tara-lu.com>) |
Ответы |
Re: will the planner ever use an index when the condition
is <> ?
|
Список | pgsql-performance |
Roxanne Reid-Bennett <rox@tara-lu.com> 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
В списке pgsql-performance по дате отправления: