| От | Tom Lane |
|---|---|
| Тема | Re: Re: Does PostgreSQL support EXISTS? |
| Дата | |
| Msg-id | 26043.992440306@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: Re: Does PostgreSQL support EXISTS? (Martijn van Oosterhout <kleptog@svana.org>) |
| Список | pgsql-general |
Martijn van Oosterhout <kleptog@svana.org> writes:
> On postgres at least, exists is faster than in.
> They are equivalent though.
Not really.
For one thing, IN can return a NULL (don't know) result; EXISTS cannot.
regression=# select * from foo;
f1
----
1
(2 rows)
regression=# select 2 in (select f1 from foo);
?column?
----------
(1 row)
regression=# select exists (select 1 from foo where f1 = 2);
?column?
----------
f
(1 row)
Yes, this behavior is spec-compliant. Think: we don't know what the NULL
represents, therefore we don't know whether 2 is in the column or not,
therefore IN should return NULL.
regards, tom lane
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера