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 по дате отправления: