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.
FROM sys.dm_db_partition_stats st
WHERE object_name(object_id) = ‘HugeTable’
Try it 🙂
Returns page and row-count information for every partition in the current database.