Re: How would I write this query...

From: "John D(dot) Burger" <john(at)mitre(dot)org>
To: PostgreSQL-general general <pgsql-general(at)postgresql(dot)org>
Subject: Re: How would I write this query...
Date: 2006-05-01 21:23:41
Message-ID: 08c9bd676d30ce46237d7469263f8ad1@mitre.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

> select *
> from people
> where id not in
> (
> select id
> from class_registration
> )

In my experience, queries like the OUTER LEFT JOIN version posted
earlier are usually much more efficient than NOT IN queries like the
above. The planner seems to be pretty smart about turning (positive)
IN queries into joins, but NOT IN queries usually turn into nested
table scans, in my experience.

- John D. Burger
MITRE

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message codeWarrior 2006-05-01 21:53:17 Re: selecting column comment
Previous Message Martijn van Oosterhout 2006-05-01 21:05:28 Re: Leading substrings - alternatives with 8.1.3?