title | description | author | ms.author | ms.date | ms.service | ms.subservice | ms.topic | monikerRange |
---|---|---|---|---|---|---|---|---|
Monitor memory-optimized system-versioned temporal tables |
Learn how to use existing views to track detailed and summarized memory consumption for every system-versioned memory-optimized table. |
rwestMSFT |
randolphwest |
07/29/2024 |
sql |
table-view-index |
conceptual |
=azuresqldb-current || >=sql-server-2016 || >=sql-server-linux-2017 || =azuresqldb-mi-current |
[!INCLUDE sqlserver2016-asdb-asdbmi]
You can use existing views to track detailed and summarized memory consumption for every system-versioned memory-optimized table.
Use the following example code to monitor temporal tables that use In-Memory OLTP. These examples make use of common table expressions (CTEs).
The following query details the memory consumption, split per main system-versioned and internal history staging table.
WITH InMemoryTemporalTables
AS (
SELECT SCHEMA_NAME(T1.schema_id) AS TemporalTableSchema,
T1.object_id AS TemporalTableObjectId,
IT.object_id AS InternalTableObjectId,
OBJECT_NAME(IT.parent_object_id) AS TemporalTableName,
IT.Name AS InternalHistoryStagingName
FROM sys.internal_tables IT
INNER JOIN sys.tables T1
ON IT.parent_object_id = T1.object_id
WHERE T1.is_memory_optimized = 1
AND T1.temporal_type = 2
)
SELECT TemporalTableSchema,
T.TemporalTableName,
T.InternalHistoryStagingName,
CASE
WHEN C.object_id = T.TemporalTableObjectId
THEN 'Temporal Table Consumption'
ELSE 'Internal Table Consumption'
END ConsumedBy,
C.*
FROM sys.dm_db_xtp_memory_consumers C
INNER JOIN InMemoryTemporalTables T
ON C.object_id = T.TemporalTableObjectId
OR C.object_id = T.InternalTableObjectId
WHERE T.TemporalTableSchema = 'dbo'
AND T.TemporalTableName = 'FXCurrencyPairs';
The following query summarizes memory consumption, with a total for a system-versioned memory-optimized table.
WITH InMemoryTemporalTables
AS (
SELECT SCHEMA_NAME(T1.schema_id) AS TemporalTableSchema,
T1.object_id AS TemporalTableObjectId,
IT.object_id AS InternalTableObjectId,
OBJECT_NAME(IT.parent_object_id) AS TemporalTableName,
IT.Name AS InternalHistoryStagingName
FROM sys.internal_tables IT
INNER JOIN sys.tables T1
ON IT.parent_object_id = T1.object_id
WHERE T1.is_memory_optimized = 1
AND T1.temporal_type = 2
),
DetailedConsumption
AS (
SELECT TemporalTableSchema,
T.TemporalTableName,
T.InternalHistoryStagingName,
CASE
WHEN C.object_id = T.TemporalTableObjectId
THEN 'Temporal Table Consumption'
ELSE 'Internal Table Consumption'
END ConsumedBy,
C.*
FROM sys.dm_db_xtp_memory_consumers C
INNER JOIN InMemoryTemporalTables T
ON C.object_id = T.TemporalTableObjectId
OR C.object_id = T.InternalTableObjectId
)
SELECT TemporalTableSchema TemporalTableName,
sum(allocated_bytes) AS allocated_bytes,
sum(used_bytes) AS used_bytes
FROM DetailedConsumption
WHERE TemporalTableSchema = 'dbo' ANDTemporalTableName = 'FXCurrencyPairs'
GROUP BY TemporalTableSchema,
TemporalTableName;
- System-versioned temporal tables with memory-optimized tables
- Create a memory-optimized system-versioned temporal table
- Work with memory-optimized system-versioned temporal tables
- Memory-optimized system-versioned temporal table performance
- Temporal tables
- Temporal table system consistency checks
- Manage retention of historical data in system-versioned temporal tables
- Temporal table metadata views and functions