Received: from sss.pgh.pa.us ([192.204.191.242]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4SIEjA77992 for ; Mon, 28 May 2001 14:14:45 -0400 (EDT) (envelope-from tgl@sss.pgh.pa.us) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.11.3/8.11.3) with ESMTP id f4SICKR13827; Mon, 28 May 2001 14:12:20 -0400 (EDT) To: Kovacs Zoltan cc: pgsql-sql@postgresql.org Subject: Re: order after WHERE clause In-reply-to: References: Comments: In-reply-to Kovacs Zoltan message dated "Mon, 28 May 2001 18:37:18 +0200" Date: Mon, 28 May 2001 14:12:19 -0400 Message-ID: <13824.991073539@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200105/301 X-Sequence-Number: 3142 Kovacs Zoltan 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