Re: <>(not equal to) in where clause can use index

From: Nicklas Avén <nicklas(dot)aven(at)jordogskog(dot)no>
To: AI Rumman <rummandba(at)gmail(dot)com>
Cc: pgsql-general General <pgsql-general(at)postgresql(dot)org>
Subject: Re: <>(not equal to) in where clause can use index
Date: 2011-02-08 09:15:06
Message-ID: 1297156506.8940.3.camel@ubuntu-nav
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

One way to get around the problem is often to do a left or right join,
use = instead of <> , and catch the rows with null in id field,
something like:

SELECT a.* from
table a LEFT JOIN tableb b on a.testfld=b.testfld
WHERE b.id is null;

This one will use indexes on testflda and testfldb an

HTH

/Nicklas

On Tue, 2011-02-08 at 15:09 +0600, AI Rumman wrote:
> Is it possible to add some operator class in Postgresql 9 so that
> <>(not equal to) in where clause can use index?
>
> If yes how?
>
> Any idea please.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Thomas Markus 2011-02-08 09:16:34 Re: many schemas or many databases
Previous Message AI Rumman 2011-02-08 09:09:01 <>(not equal to) in where clause can use index