Re: ***SPAM*** Re: Can I get the number of results plus the results with a single query?

Поиск
Список
Период
Сортировка
От Rob Sargent
Тема Re: ***SPAM*** Re: Can I get the number of results plus the results with a single query?
Дата
Msg-id a9e48f38-93b6-89b4-34c2-3b34bd6732b8@gmail.com
обсуждение исходный текст
Ответ на Re: ***SPAM*** Re: Can I get the number of results plus the results with a single query?  (Perry Smith <pedz@easesoftware.com>)
Ответы Re: ***SPAM*** Re: Can I get the number of results plus the results with a single query?  ("Walter Dörwald" <walter@livinglogic.de>)
Список pgsql-general
On 8/15/22 14:37, Perry Smith wrote:


On Aug 15, 2022, at 08:55, David G. Johnston <david.g.johnston@gmail.com> wrote:

On Monday, August 15, 2022, Perry Smith <pedz@easesoftware.com> wrote:
I’ve been toying with row_number() and then sort by row_number descending and pick off the first row as the total number. 

Use count as a window function.

I see others are commenting after David’s update so:

Thank you David.

This seems to work for me:

SELECT count(*) OVER (), id, basename, sha1 FROM dateien WHERE (lower(ext) in ( 'pxd' ) and ftype = 'file') ORDER BY sha1;

This has, e.g. 73, in the first column for all of the rows.

Any comparative timing statistics on that?  Especially on more than 73 records returned, because with that few just grab them all and get size() or length of what ever collection mechanism you're playing with.

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

Предыдущее
От: Perry Smith
Дата:
Сообщение: Re: ***SPAM*** Re: Can I get the number of results plus the results with a single query?
Следующее
От: Abdul Qoyyuum
Дата:
Сообщение: Re: Help regarding Multi Tenancy with PostgreSQL