Re: select single entry and its neighbours using direct-acess to index?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: select single entry and its neighbours using direct-acess to index?
Дата
Msg-id 1708.1102347658@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: select single entry and its neighbours using direct-acess to index?  (Pierre-Frédéric Caillaud<lists@boutiquenumerique.com>)
Ответы Re: select single entry and its neighbours using direct-acess to index?
Список 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 по дате отправления:

Предыдущее
От: Martijn van Oosterhout
Дата:
Сообщение: Re: Performance tuning on RedHat Enterprise Linux 3
Следующее
От: "C G"
Дата:
Сообщение: triggers, transactions and locks