Forum OpenACS Development: not in statement

Collapse
Posted by Malte Sussdorff on
I just realized how badly "not in" statements behave in PostgreSQL especially if you compare two big tables.

What you can do instead is a left join where you limit the result to the objects where the joined table has no entry. For contacts we have this:

select person_id from persons left join (select item_id from cr_items where content_type = 'contact_party_revision') items on item_id = person_id where item_id is null;

Did I make a magnificent mistake or is there a reason why google search did not bring this up on a prominent spot when searching for "postgres not in"

Collapse
2: Re: not in statement (response to 1)
Posted by Steve Manning on
"In" is such a common word that Google will ignore it in most contexts - try quoting it

    postgres "not in"

or


    postgres "not in" performance

See what that returns.


    - Steve