Re: Returning the total number of rows as a separate column when using limit
От | Gregory Stark |
---|---|
Тема | Re: Returning the total number of rows as a separate column when using limit |
Дата | |
Msg-id | 873avjx3kc.fsf@oxford.xeocode.com обсуждение исходный текст |
Ответ на | Re: Returning the total number of rows as a separate column when using limit (Gregory Stark <stark@enterprisedb.com>) |
Список | pgsql-sql |
"Gregory Stark" <stark@enterprisedb.com> writes: > "Andreas Joseph Krogh" <andreak@officenet.no> writes: > >> That's what I'm doing now. I run the query with "limit+1" as limit and if it >> results in more than limit, I know there is more data and I run count(*) to >> count them all. But count(*) cannot use indices in PG so it's limited in >> speed anyway AFAICS. > > Well count(*) can use indexes the same as the query can. > >> I really hoped there was an "Oracle over()" equivalent way in PG. I understand >> that Oracle's LIMIT-hack with "3 subselects and rownum between 1 AND 20" is >> rather expensive compared to PG's implementation of LIMIT. Oralce keeps >> snapshot-info in the index, so counting only involves the index AFAIK. > > Well that's only going to be true if the index satisfies the whole query which > is not going to be true for the simplest cases. er, *except* for the simplest cases. -- Gregory Stark EnterpriseDB http://www.enterprisedb.com Ask me about EnterpriseDB's RemoteDBA services!
В списке pgsql-sql по дате отправления: