Re: Query plan for "heavy" SELECT with "lite" sub-SELECTs
В списке pgsql-performance по дате отправления:
| От | Tom Lane |
|---|---|
| Тема | Re: Query plan for "heavy" SELECT with "lite" sub-SELECTs |
| Дата | |
| Msg-id | 1994.1162565453@sss.pgh.pa.us обсуждение исходный текст |
| Ответ на | Re: Query plan for "heavy" SELECT with "lite" sub-SELECTs (Arjen van der Meijden <acmmailing@tweakers.net>) |
| Список | pgsql-performance |
Arjen van der Meijden <acmmailing@tweakers.net> writes:
> ... Rewriting it to something like this made the last iteration about as
> fast as the first:
> SELECT docid, (SELECT work to be done for each document)
> FROM documents
> WHERE docid IN (SELECT docid FROM documents
> ORDER BY docid
> LIMIT 1000
> OFFSET ?
> )
The reason for this, of course, is that the LIMIT/OFFSET filter is the
last step in a query plan --- it comes *after* computation of the SELECT
output list. (So does ORDER BY, if an explicit sort step is needed.)
So if you have an expensive-to-compute output list, a trick like Arjen's
will help. I don't think you can use an "IN" though, at least not if
you want to preserve the sort ordering in the final result.
regards, tom lane
В списке pgsql-performance по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера