pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
order after WHERE clause
2+ messages / 2 participants
[nested] [flat]

* order after WHERE clause
@ 2001-05-28 16:37 Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
  2001-05-28 18:12 ` Re: order after WHERE clause Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 2+ messages in thread

From: Kovacs Zoltan @ 2001-05-28 16:37 UTC (permalink / raw)
  To: pgsql-sql

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;

In general, is it important how I define the ordering in a WHERE clause?

TIA, Zoltan

-- 
                         Kov\'acs, Zolt\'an
                         kovacsz@pc10.radnoti-szeged.sulinet.hu
                         http://www.math.u-szeged.hu/~kovzol
                         ftp://pc10.radnoti-szeged.sulinet.hu/home/kovacsz




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: order after WHERE clause
  2001-05-28 16:37 order after WHERE clause Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
@ 2001-05-28 18:12 ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 2+ messages in thread

From: Tom Lane @ 2001-05-28 18:12 UTC (permalink / raw)
  To: Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>; +Cc: pgsql-sql

Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.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



^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2001-05-28 18:12 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2001-05-28 16:37 order after WHERE clause Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
2001-05-28 18:12 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox