Best method for getting total record count | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Best method for getting total record count

I have a system that contains about 1.5 mil rows of data that can searched by one or more criteria. The portal will only return back 300 results at a time which meets the client expectation. Essentially using a TOP 300 gives the matching results and performance is good. New requirement would still show the total matching records despite only 300 being returned. Something like Results 21-30 of 300 Total Matching 748,120. I notice that doing a statement like the following is quick – but is there a better way: SELECT COUNT(*)
FROM tblBigTable WITH (NOLOCK)
WHERE condition 1…
AND condition 2…
You don’t have to return all the rows to the client. You canpage across the resultset in SQL Server if there is a unique number in the resultset. Look for paging records in this forum. Gaurav
Moderator
Man thrives, oddly enough, only in the presence of a challenging environment- L. Ron Hubbard

The views expressed here are those of the author and no one else. There are no warranties as to the reliability or accuracy of anything presented here.
I can see the method used is only the way to get out the result, follow as suggested. Satya SKJ
Moderator
http://www.SQL-Server-Performance.Com/forum
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
]]>