From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Merlin Moncure <merlin.moncure@rcsonline.com>
Cc: Carlos Benkendorf <carlosbenkendorf@yahoo.com.br>
Cc: pgsql-performance@postgresql.org
Subject: Re: Improving performance of a query
Date: Tue, 6 Sep 2005 07:09:08 -0700 (PDT)
Message-ID: <20050906070119.K35524@megazone.bigpanda.com> (raw)
In-Reply-To: <6EE64EF3AB31D5448D0007DD34EEB3417DD278@Herge.rcsinc.local>
References: <6EE64EF3AB31D5448D0007DD34EEB3417DD278@Herge.rcsinc.local>
On Tue, 6 Sep 2005, Merlin Moncure wrote:
> Carlos wrote:
> SELECT * FROM SSIRRA where
> (YEAR = 2004 and CUSTOMER = 0000000004 and CODE = 00 and PART >= 00) or
> (YEAR = 2004 and CUSTOMER = 0000000004 and CODE > 00) or
> (YEAR = 2004 and CUSTOMER > 0000000004) or
> (YEAR > 2004)
> [snip]
>
> ah, the positional query. You can always rewrite this query in the
> following form:
>
> (YEAR >= 2004) and
> (YEAR = 2004 or CUSTOMER >= 0000000004) and
> (YEAR = 2004 or CUSTOMER = 0000000004 or CODE >= 00) and
> (YEAR = 2004 or CUSTOMER = 0000000004 or CODE = 00 or PART > 00)
Unless I'm not seeing something, I don't think that's a correct
reformulation in general. If customer < 4 and year > 2004 the original
clause would return true but the reformulation would return false since
(year=2004 or customer >= 4) would be false.
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-performance@postgresql.org
Cc: sszabo@megazone.bigpanda.com, merlin.moncure@rcsonline.com, carlosbenkendorf@yahoo.com.br
Subject: Re: Improving performance of a query
In-Reply-To: <20050906070119.K35524@megazone.bigpanda.com>
* 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