sys.dm_db_xtp_object_stats – Day 69 – One DMV a Day

Hello Geeks and welcome to the Day 69 of the long series of One DMV a day. In this series of blogs I will be exploring and explaining the most useful DMVs in SQL Server. As we go ahead in this series we will also talk about the usage, linking between DMVs and some scenarios where these DMVs will be helpful while you are using SQL Server. For the complete list in the series please click here.

Yesterday I have covered sys.dm_db_xtp_checkpoint_stats. Today I will be covering sys.dm_db_xtp_object_stats. This DMV is useful when you are troubleshooting high usage object in your In-Memory OLTP engine. Again this is a stats related DMV and the output is aggregated from last restart.

To understand the output of sys.dm_db_xtp_object_stats I will start by first restarting my SQL instance. When I restart the stats are set to the basic values. So let us see the output of first attempt.

SELECT o.name,
	row_insert_attempts,
	row_update_attempts,
	row_delete_attempts,
	write_conflicts,
	unique_constraint_violations
FROM sys.dm_db_xtp_object_stats xos
INNER JOIN sys.objects o
ON xos.object_id = o.object_id
WHERE o.name = 'inMem_tbl'

sys.dm_db_xtp_object_stats 1

From the above output you can see there were 10000 insert attempts and 25000 update attempts already. This is because the whole table is rebuilt in the memory for durable tables. If this has been a non-durable table the counts would be zeros. Now let us run an update from two sessions so there will be a conflict.

UPDATE inMem_tbl
SET col2 = col2
WHERE col1 > 5000

One of them will fail with below error.

sys.dm_db_xtp_object_stats Conflict

Let us see the output again from sys.dm_db_xtp_object_stats.

sys.dm_db_xtp_object_stats 2

From the output you can see that the update attempts increased by only 5000 which is one update statement. As one of them failed the update attempts were not recorded. But the conflict count has increased to 1. This is how the counts and other columns affect in sys.dm_db_xtp_object_stats.

Tomorrow I will be covering another In-Memory optimized tables related DMV. So stay tuned. Till then

Happy Learning,
Manu

Like us on FaceBook | Join the fastest growing SQL Server group on FaceBook |
Follow me on Twitter | Follow me on FaceBook

Avatar

About Manohar Punna

Manohar Punna is a Microsoft Data Platform Consultant and a Data Platform MVP. In his day to day job he works on building database and BI systems, automation, building monitoring systems, helping customers to make value from their data & explore and learn. By passion Manohar is a blogger, speaker and Vice President of DataPlatformGeeks. He is a community enthusiast and believes strongly in the concept of giving back to the community. Manohar is a speaker at various Data Platform events from SQL Server Day, various user groups, SQLSaturdays, SQLBits, MS Ignite, SSGAS & DPS. His One DMV a Day series is the longest one day series on any topic related to SQL Server available so far.

View all posts by Manohar Punna →

Leave a Reply

Your email address will not be published. Required fields are marked *