Re: Why is there a Sort after an Index Only Scan?

Поиск
Список
Период
Сортировка
От Jeff Janes
Тема Re: Why is there a Sort after an Index Only Scan?
Дата
Msg-id CAMkU=1yjuKjFKsZ3h2yuwGHCZxm==yp6C2gim-tXh6q3xK51Lg@mail.gmail.com
обсуждение исходный текст
Ответ на Why is there a Sort after an Index Only Scan?  (André Hänsel <andre@webkr.de>)
Список pgsql-performance
On Wed, May 4, 2022 at 7:15 PM André Hänsel <andre@webkr.de> wrote:
Quick(?) question... why is there a Sort node after an Index Only Scan?
Shouldn't the index already spit out sorted tuples?

CREATE INDEX ON orders_test(shipping_date, order_id);

EXPLAIN ANALYZE SELECT
FROM orders_test
WHERE TRUE
AND shipping_date >= '2022-05-01'
AND shipping_date <= '2022-05-01'
ORDER BY order_id
LIMIT 50;

They are sorted by order_id only within sets of the same shipping_date, which is not good enough.  (It would be good enough if it were smart enough to know that there is only one possible shipping date to satisfy your weird range condition.)
 
Cheers,

Jeff

В списке pgsql-performance по дате отправления:

Предыдущее
От: André Hänsel
Дата:
Сообщение: Why is there a Sort after an Index Only Scan?
Следующее
От: David Rowley
Дата:
Сообщение: Re: Why is there a Sort after an Index Only Scan?