Labels

ASP.NET (1) Data Model (1) Django (1) MDX (15) Python (3) Redshift (3) SSAS (15) SSRS (3) T-SQL (29)

Monday, 18 June 2012

Fastest Performing Rowcount SQL Query

Try executing the below queries in a table containing millins of records. Both the queries yields row count of the table, but the performance of Query 1 is more.

Query 1:


SELECT SUM(row_count) FROM Sys.dm_db_partition_stats
WHERE OBJECT_ID = OBJECT_ID('AccountCommunications')
AND (index_id =0 or index_id =1);

Query 2:
Select COUNT(*) From dbo.AccountCommunications

No comments:

Post a Comment