Re: Weird NOT IN effect with NULL values

Поиск
Список
Период
Сортировка
От Josh Berkus
Тема Re: Weird NOT IN effect with NULL values
Дата
Msg-id 3A9E95A7.63FE080D@agliodbs.com
обсуждение исходный текст
Ответ на Weird NOT IN effect with NULL values  (Frank Joerdens <frank@joerdens.de>)
Ответы Re: Weird NOT IN effect with NULL values  (Bruce Momjian <pgman@candle.pha.pa.us>)
Список pgsql-sql
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
informationtechnology      josh@agliodbs.com   and data management solutions       (415) 565-7293  for law firms, small
businesses      fax  621-2533   and non-profit organizations.       San Francisco
 


В списке pgsql-sql по дате отправления:

Предыдущее
От: Frank Joerdens
Дата:
Сообщение: Weird NOT IN effect with NULL values
Следующее
От: Bruce Momjian
Дата:
Сообщение: Re: Weird NOT IN effect with NULL values