Re: IN, EXISTS or ANY?
От | Tom Lane |
---|---|
Тема | Re: IN, EXISTS or ANY? |
Дата | |
Msg-id | 17935.1020056063@sss.pgh.pa.us обсуждение исходный текст |
Ответ на | IN, EXISTS or ANY? ("Josh Berkus" <josh@agliodbs.com>) |
Ответы |
Re: IN, EXISTS or ANY?
|
Список | pgsql-sql |
"Josh Berkus" <josh@agliodbs.com> writes: > I was wondering if there is any difference in execution speed for the > following three statements: > WHERE case_id IN (SELECT case_id FROM case_clients > WHERE matter_no = '123.122342'); > or: > WHERE case_id = ANY (SELECT case_id FROM case_clients > WHERE matter_no = '123.122342'); > or > WHERE EXISTS ( SELECT case_id FROM case_clients > WHERE matter_no = '123.122342' > AND case_id = cases.case_id); IN is the same as = ANY (cf. row_expr production in src/backend/parser/gram.y for implementation, or SQL92 8.4 rule 4 for specification; there ain't *no* difference). But EXISTS is an entirely different animal which is often faster ... isn't that in the FAQ? regards, tom lane
В списке pgsql-sql по дате отправления: