From: Merlin Moncure <mmoncure@gmail.com>
To: Kevin Grittner <Kevin.Grittner@wicourts.gov>
Cc: pgsql-hackers@postgresql.org
Cc: pgsql-performance@postgresql.org
Subject: Re: [PERFORM] BETWEEN optimizer problems with single-value range
Date: Wed, 15 Mar 2006 14:36:51 -0500
Message-ID: <b42b73150603151136wd1a8b1dw6e03d39f07fd6cb@mail.gmail.com> (raw)
In-Reply-To: <44180105.EE98.0025.0@wicourts.gov>
References: <44180105.EE98.0025.0@wicourts.gov>
On 3/15/06, Kevin Grittner <Kevin.Grittner@wicourts.gov> wrote:
> Attached is a simplified example of a performance problem we have seen,
> with a workaround and a suggestion for enhancement (hence both the
> performance and hackers lists).
Hi Kevin. In postgres 8.2 you will be able to use the row-wise
comparison for your query which should guarantee good worst case
performance without having to maintain two separate query forms. it
is also a more elegant syntax as you will see.
SELECT "CA"."calDate", "CA"."startTime"
FROM "Cal" "CA"
WHERE ("CA"."ctofcNo", "CA"."calDate") BETWEEN
(2192, '2006-03-15') and (2192, '2006-03-15')
ORDER BY "ctofcNo", "calDate", "startTime";
Be warned this will not work properly in pg < 8.2. IMO, row-wise is
the best way to write this type of a query. Please note the row
constructor and the addition of ctofcNo into the order by clause to
force use of the index.
Merlin
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-performance@postgresql.org
Cc: mmoncure@gmail.com, Kevin.Grittner@wicourts.gov, pgsql-hackers@postgresql.org
Subject: Re: [PERFORM] BETWEEN optimizer problems with single-value range
In-Reply-To: <b42b73150603151136wd1a8b1dw6e03d39f07fd6cb@mail.gmail.com>
References: <44180105.EE98.0025.0@wicourts.gov> <b42b73150603151136wd1a8b1dw6e03d39f07fd6cb@mail.gmail.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