Use this Query,
SELECT rows FROM sysindexes
WHERE id = OBJECT_ID('table_name') AND indid < 2
This is the better way to get the count of records from a table. If you use select count(*), this statement make a full table scan to return the total table's row count, it can take very many time for the large table. There is another way to determine the total row count in a table. You can use sysindexes system table, in this case. There is ROWS column in the sysindexes table. This column contains the total row count for each table in your database. So, this query provides better performance. So, you can improve the speed of such queries in several times.
No comments:
Post a Comment