Re: Efficient way to count rows when using GROUP BY

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If you don't want a group count, but want a total row count instead, there's 
no reason to have the group by statement, If you're trying to have a 
conglomerate result, where one column is always equal to the total count, 
wouldn't it be more efficient to have a seperate query for that?

-Micah 


> Hi All,
>
> I use
>
> SELECT COUNT(*) FROM whatever WHERE whatever
>
> to determine how many rows a particular query will return (then use this
> count to assist with pagination).
>
> The problem is that this does not work if the query contains a GROUP BY
> statement as, of course, the query will return many rows each with a count
> by each grouping.
>
> Does anyone know an efficient way to determine the number of ROWS a query
> with a GROUP BY statement will return (without just executing the entire
> query with no LIMIT statement)?
>
> Thanks ... Ross

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux