Search
Free Signup | Login
Search Articles
Topics
Article List
Article Archive
Relevant Links
Get Approximate Row Count Fast on SQL Server
Location: BlogsRevindexSQL    
Posted by: revindex 9/26/2008 4:51 AM

Row count can be extremely long for very tables with thousands or millions of rows. SQL Server is already optimized to count from the index instead of counting from the data table, but the operation can still take seconds, if not minutes to complete. If you don't need the exact number of rows, you can use the following query to get an approximate row count quickly on SQL Server:

SELECT rowcnt FROM sys.sysindexes WHERE id = OBJECT_ID('TABLE_NAME') AND indid < 2

where TABLE_NAME is the name of your table.

 

Permalink |  Trackback

Your name:
Title:
Comment:
Add Comment   Cancel