July 25, 2008 at 1:28 pm
SELECT name, (leaf_delete_count+leaf_ghost_count
FROM master.sys.dm_db_index_operational_stats(db_id('test'),NULL,NULL,NULL) T
join test.sys.sysobjects S (nolock)
on S.id = T.object_id
where T.index_id=1
and S.xtype='U'
and database_id =DB_ID(N'test')
We use the above query to figure out how many deletion happens in our database. But seems the leaf_ghost_count is really tricky. It does not work in one situation.
Say you are deleting 100,000 rows from a table, you stop the query during its run. When check the data in the table, it still has all the rows there(rolled back for you). But leaf_ghost_count gets increased.
Wondering:
1). Is there any better ways to get deletion stats other than triggers(on every table)?
2). How does dm_db_index_operational_stats work? (when rollback happens)
Thanks for your input.
July 25, 2008 at 6:58 pm
Might this be the source of confusion:
From the definition of: sys.dm_db_index_operational_stats
Cumulative count of leaf-level rows that are marked as deleted, but not yet removed. These rows are removed by a cleanup thread at set intervals
See
July 30, 2008 at 1:15 pm
Thanks for the reply.
Of course, we read the BOL. But it does not mention explicitly the rollback scenario. Also looking for any alternatives.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply