Sys.dm_db_partition_stats table?

  • I was looking this morning for a way to find the row count of all of the tables in one of our databases. I stumbled upon this query:

    SELECT OBJECT_NAME(OBJECT_ID) TableName, st.row_count

    FROM sys.dm_db_partition_stats st

    WHERE index_id < 2

    ORDER BY st.row_count DESC

    Source[/url]

    It seems to work really well. However, I don't understand the index_id in this table (sys.dm_db_partition_stats). Does anyone have an explanation for the purpose of this table and what this index_id is referring to? MSDN says:

    ID of the heap or index the partition is part of.

    0 = Heap

    1 = Clustered index.

    > 1 = Nonclustered index

    But that was Greek to me! I'm really interested in learning, so any light on the subject is appreciated.

  • Well, first, I'd suggest hitting up the Stairway to SQL Server Indexes[/url] here, to get an understanding of what indexes are, what the types of indexes are, and how they're used...

    I suspect after your give the stairway a read, it'll be a little clearer...

    🙂

    Jason

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply