top of page

DMVs for memory-optimized tables

The goal of using memory-optimized tables is to execute processes as quickly as possible. Therefore, you should enable collection of execution statistics for natively compiled stored procedures.

Consequently, you could be surprised that some statistics, such as worker_time and elapsed_time, do not get collected by DMVs such as sys.dm_exec_query_stats and sys.dm_exec_procedure_stats. In fact, these DMVs include no information about natively compiled stored procedures.

Instead, you need to specifically enable the collection of execution statistics by using one of the following system stored procedures:

  • sys.sp_xtp_control_proc_exec_stats Use this system stored procedure to enable statistics collection for your SQL Server instance at the procedure level.

  • sys.sp_xtp_control_query_exec_stats Use this system stored procedure to enable statistics collection at the query level for selected natively compiled stored procedures.

Taken together, use the system stored procedures sys.sp_xtp_control_proc_exec_stats and sys.sp_xtp_control_query_exec_stats to enable or disable the collection of execution statistics for natively compiled stored procedures at the procedure level or query level, respectively.

After enabling statistics collection, use the sys.dm_exec_procedure_stats and sys.dm_exec_query_stats DMVs to review the statistics.

It is worth noting that in some cases, however, you cannot even use DMVs for disk-based tables in memory-optimized tables. For example, if you want to look at the usage of indexes in memory-optimized tables, you must use sys.dm_db_xtp_index_stats, instead of sys.dm_db_index_usage_stats (For disk-based table, use sys.dm_db_index_usage_stats to review current index usage or, in combination with sys.indexes and sys.objects, to find indexes that are never used.)

 

Example:

Answer:

bottom of page