Home » Database » Fastest way to Count Millions of Rows in an Extremely Large Table

Fastest way to Count Millions of Rows in an Extremely Large Table

SELECT COUNT(*) from tableName

can take lot of minutes to execute row count information

 

but if we use this query then it would take hardly 1-2 seconds to return row counts even if the table has millions of rows.

SELECT SUM(st.row_count)

FROM sys.dm_db_partition_stats st

WHERE object_name(object_id) = ‘HugeTable’

 

Try it ­čÖé

Note:

sys.dm_db_partition_stats :

Returns page and row-count information for every partition in the current database.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *

www.000webhost.com