Re: Search query is curious

Поиск
Список
Период
Сортировка
От Maciek Sakrejda
Тема Re: Search query is curious
Дата
Msg-id AANLkTim0gvJ9xtvNEbRLxVM1DYBjOOYCZ5TzH5zb+Kzp@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Search query is curious  (Pavel Stehule <pavel.stehule@gmail.com>)
Список pgsql-performance
> without ORDER BY database returns first 15 rows where predicate is
> true. With ORDER BY the database has to find all rows where predicate
> is true and then has to sort it. So first case can be a much faster
> because there are not necessary full table scan.

Right. Essentialy, the ORDER BY happens before the LIMIT (so you have
to sort everything before you take the first 15). If it were the other
way around, you would take the first 15 rows Postgres happens to find
(in an arbitrary order) and then sort these 15, which is probably not
that useful. Consider Thom's suggestion.

---
Maciek Sakrejda | System Architect | Truviso

1065 E. Hillsdale Blvd., Suite 215
Foster City, CA 94404
(650) 242-3500 Main
www.truviso.com

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

Предыдущее
От: Alvaro Herrera
Дата:
Сообщение: Re: Quesion on the use of indexes
Следующее
От:
Дата:
Сообщение: Re: Quesion on the use of indexes