pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Josh Berkus <josh@agliodbs.com>
To: sqllist <pgsql-sql@postgresql.org>
Subject: Re: Weird NOT IN effect with NULL values
Date: Thu, 01 Mar 2001 10:32:07 -0800
Message-ID: <3A9E95A7.63FE080D@agliodbs.com> (raw)
References: <20010301191654.A12406@rakete.joerdens.de>

Mr. Joerdens,

> I get no rows if the result column returned by the subselect
> contains NULL values. It works as expected if I remove the NULL values
> from the result set. Is this behaviour correct and if so, why?

I can see how that bug would happen.  You may want to forward your
e-mail to pgsql-bugs.

Regardless, you'll find that you get faster results (as well as avoiding
the NULL bug) if you use the following form of the query:

SELECT name
FROM customer
WHERE NOT EXISTS (
SELECT customer_id
FROM salesorder
WHERE customer_id = customer.customer_id
);

Bruce, you may want to consider editing your next edition to include the
above modification.  WHERE ... NOT IN is a bad idea for any subselect on
medium-large tables.

-Josh Berkus


-- 
______AGLIO DATABASE SOLUTIONS___________________________
                                        Josh Berkus
   Complete information technology      josh@agliodbs.com
    and data management solutions       (415) 565-7293
   for law firms, small businesses       fax  621-2533
    and non-profit organizations.       San Francisco



view thread (8+ messages)  latest in thread

Message-ID: <3A9E95A7.63FE080D@agliodbs.com>
Permalink:  ../3A9E95A7.63FE080D@agliodbs.com/
Also on:    postgresql.org/message-id/3A9E95A7.63FE080D@agliodbs.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: josh@agliodbs.com
  Subject: Re: Weird NOT IN effect with NULL values
  In-Reply-To: <3A9E95A7.63FE080D@agliodbs.com>
  References: <20010301191654.A12406@rakete.joerdens.de> <3A9E95A7.63FE080D@agliodbs.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox