From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Josh Berkus" <josh(at)agliodbs(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: IN, EXISTS or ANY? |
Date: | 2002-04-29 04:54:23 |
Message-ID: | 17935.1020056063@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
"Josh Berkus" <josh(at)agliodbs(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Josh Berkus | 2002-04-29 05:24:53 | Re: IN, EXISTS or ANY? |
Previous Message | Josh Berkus | 2002-04-29 04:44:55 | IN, EXISTS or ANY? |