Quickly count rows in a large SQL table.
Instead of using this:
SELECT COUNT(*) FROM MyTable
use this (it's quicker):
SELECT
Total_Rows= SUM(st.row_count)
FROM
sys.dm_db_partition_stats st
WHERE
object_name(object_id) = 'MyTable' AND (index_id < 2)
Written by Carlotta Tatti
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Sql
Authors
Related Tags
#sql
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#