Re: [GENERAL] Combining count() and row_number() as window functions

2017-01-19 Thread Stephen Frost
Tom, * Tom Lane (t...@sss.pgh.pa.us) wrote: > Thomas Kellerer writes: > > I assumed that the count() wouldn't increase the runtime of the query as > > the result of the row_number() can be used to calculate that. > > No such knowledge exists in Postgres. Given our general

Re: [GENERAL] Combining count() and row_number() as window functions

2017-01-19 Thread Tom Lane
Thomas Kellerer writes: > I assumed that the count() wouldn't increase the runtime of the query as the > result of the row_number() can be used to calculate that. No such knowledge exists in Postgres. Given our general approach in which functions (including window

[GENERAL] Combining count() and row_number() as window functions

2017-01-19 Thread Thomas Kellerer
I was playing around with a query that essentially looked something like this: select row_number() over (order by foo_date) as rn, count(*) over () as total_count, f.* from foo f; (The actual query limits the output based on the row_number() for pagination