Re: [PERFORM] Find original number of rows before applied LIMIT/OFFSET?
В списке pgsql-general по дате отправления:
| От | Greg Stark |
|---|---|
| Тема | Re: [PERFORM] Find original number of rows before applied LIMIT/OFFSET? |
| Дата | |
| Msg-id | 873carwnqn.fsf@stark.dyndns.tv обсуждение |
| Ответ на | Find original number of rows before applied LIMIT/OFFSET? ("D. Dante Lorenso" <dante@lorenso.com>) |
| Список | pgsql-general |
"D. Dante Lorenso" <dante@lorenso.com> writes: > Any thoughts? Sure, the PHP function I'm using above 'works', but is it > the most efficient? I hope I'm not actually pulling all 100,000 records > across the wire when I only intend to show 10 at a time. See what I'm > getting at? I tend to do it using a separate select count(*). My thinking is that the count(*) query can be simplified and exclude things like the ORDER BY clause and any select list entries that require extra work. It can often even exclude whole joins. By doing a separate query I can do that extra work only for the rows that i actually need for display. Hopefully using an index to pull up those rows. And do the count(*) in the most efficient way possible, probably a sequential scan with no joins for foreign keys etc. But I suspect the two methods both work out to suck about equally. -- greg
В списке pgsql-general по дате отправления:
Сайт использует файлы cookie для корректной работы и повышения удобства. Нажимая кнопку «Принять» или продолжая пользоваться сайтом, вы соглашаетесь на их использование в соответствии с Политикой в отношении обработки cookie ООО «ППГ», в том числе на передачу данных из файлов cookie сторонним статистическим и рекламным службам. Вы можете управлять настройками cookie через параметры вашего браузера