pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Kovacs Zoltan <kovacsz@pc10.radnoti-szeged.sulinet.hu>
Cc: pgsql-sql@postgresql.org
Subject: Re: order after WHERE clause
Date: Mon, 28 May 2001 14:12:19 -0400
Message-ID: <13824.991073539@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.4.21.0105281833300.14681-100000@pc10.radnoti-szeged.sulinet.hu>
References: <Pine.LNX.4.21.0105281833300.14681-100000@pc10.radnoti-szeged.sulinet.hu>

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



view thread (2+ messages)

Message-ID: <13824.991073539@sss.pgh.pa.us>
Permalink:  ../13824.991073539@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/13824.991073539@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: tgl@sss.pgh.pa.us, kovacsz@pc10.radnoti-szeged.sulinet.hu
  Subject: Re: order after WHERE clause
  In-Reply-To: <13824.991073539@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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