Re: select single entry and its neighbours using direct-acess to index? - Mailing list pgsql-general

From Tom Lane
Subject Re: select single entry and its neighbours using direct-acess to index?
Date
Msg-id 1708.1102347658@sss.pgh.pa.us
Whole thread Raw
In response to Re: select single entry and its neighbours using direct-acess to index?  (Pierre-Frédéric Caillaud<lists@boutiquenumerique.com>)
Responses Re: select single entry and its neighbours using direct-acess to index?  (Pierre-Frédéric Caillaud<lists@boutiquenumerique.com>)
List pgsql-general
=?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= <lists@boutiquenumerique.com> writes:
> SELECT * FROM test WHERE (name='b' and name2>'a') OR (name>'b') ORDER BY
> name,name2 ASC LIMIT 1;
>> Write that WHERE clause instead as:
>> WHERE name>='b' AND (name>'b' OR (name='b' AND name2>'a'))
>> This is logically equivalent, but it gives the planner a better handle on
>> how to use an index scan to satisfy the query.

>     I thought the planner had an automatic rewriter for these situations.

No.  There was a prior discussion of this, saying that we really ought
to support the SQL-spec row comparison syntax:
    ... WHERE (name, name2) > ('b', 'a');
which would map directly onto the semantics of a 2-column index.  We
don't have that functionality yet, though (we take the syntax but the
semantics are not SQL-compliant) let alone any ability to pass it
through to a 2-column index.

            regards, tom lane

pgsql-general by date:

Previous
From: Martijn van Oosterhout
Date:
Subject: Re: Performance tuning on RedHat Enterprise Linux 3
Next
From: "C G"
Date:
Subject: triggers, transactions and locks