Hello Geeks and welcome to the Day 74 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 we have seen how to check the queues using sys.dm_xtp_gc_queue_stats. Today I will be covering how the transactions are kept track of using sys.dm_db_xtp_gc_cycle_stats. This DMV shows the current state of committed transactions which have deleted at least one row. These transactions are grouped into unit of 16 transactions across 16 generations.
The generations hold a specific set of transactions. Below is the grouping description of generations shown in sys.dm_db_xtp_gc_cycle_stats for each cycle.
Generation 0: The transactions committed before the oldest active transaction. The row versions of these transactions can be immediately collected.
Generation 1-14: The transactions greater than the oldest active transaction. These cannot be collected. Also each generation can hold up to 16 transactions. This makes it possible to hold 16*14 = 224 transactions.
Generation 15: The remaining transactions are accounted here. This has no limit but very high growing value may indicate huge open transactions.
Let us see the truncated version of sys.dm_db_xtp_gc_cycle_stats. I am running less number of transactions on my In-Memory tables and the transactions never go beyond Generation 1. In most of OLTP loads you will see this going into multiple Generations and even into Generation 15.
SELECT cycle_id, ticks_at_cycle_start, ticks_at_cycle_end, base_generation, xacts_copied_to_local, xacts_in_gen_0, xacts_in_gen_1, xacts_in_gen_15 FROM sys.dm_db_xtp_gc_cycle_stats
Two more columns which we should know from sys.dm_db_xtp_gc_cycle_stats are the base_generation and xacts_copied_to_local. Base_generation is the timestamp of oldest active transaction. This always increments with 16. The first value we see is 113. The next value it is updated to 113 + 16 = 129 + 16 = 145. Xacts_copied_to_local is the number of transactions which are copied into the generation array.
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