From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Kovacs Zoltan <kovacsz(at)pc10(dot)radnoti-szeged(dot)sulinet(dot)hu> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: order after WHERE clause |
Date: | 2001-05-28 18:12:19 |
Message-ID: | 13824.991073539@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Kovacs Zoltan <kovacsz(at)pc10(dot)radnoti-szeged(dot)sulinet(dot)hu> writes:
> Is it possible that I get different query result time if I change two
> parts of the WHERE clause? I.e.,
> SELECT * FROM table WHERE col1 = 5 AND col2 = 6;
> and
> SELECT * FROM table WHERE col2 = 6 AND col1 = 5;
It's possible that could matter if there are two alternative query plans
that are estimated to have the exact same cost by the planner --- in
that situation, the first one considered will be preferred, and the
ordering of WHERE clauses could affect the order in which alternatives
are examined. The odds of this happening are pretty small, I think,
unless (a) you've never vacuum analyzed or (b) the data statistics are
in fact identical for the two columns. But in case (b) it shouldn't
matter which plan is picked anyway.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Tim Barnard | 2001-05-28 19:13:48 | Re: [SQL] Very big problem |
Previous Message | Tom Lane | 2001-05-28 17:47:00 | Re: Problems with pg_dump (on Debian i386) |