| От | Tom Lane |
|---|---|
| Тема | Re: The usual sequential scan, but with LIMIT ! |
| Дата | |
| Msg-id | 29692.1094564867@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: The usual sequential scan, but with LIMIT ! (Pierre-Frédéric Caillaud<lists@boutiquenumerique.com>) |
| Ответы |
Re: The usual sequential scan, but with LIMIT !
|
| Список | pgsql-performance |
=?iso-8859-15?Q?Pierre-Fr=E9d=E9ric_Caillaud?= <lists@boutiquenumerique.com> writes:
> suppose I SELECT WHERE topic_id=2 ORDER BY topic_id ASC,id DESC.
> Postgres does a seq scan, but it could think a bit more and start at
> "first index node which has topic_id>2" (simple to find in a btree) then
> go backwards in the index.
If you write it as
SELECT WHERE topic_id=2 ORDER BY topic_id DESC,id DESC.
then an index on (topic_id, id) will work fine. The mixed ASC/DESC
ordering is not compatible with the index.
regards, tom lane
В списке pgsql-performance по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера