[SQL Server] In-Memory OLTP : Afficher les informations détaillées sur les consommateurs de mémoire au niveau de la base de données

DROP TABLE IF EXISTS #RAM_Consumers

select
object_id, xtp_object_id ,convert(decimal(9,3),sum(allocated_bytes) / 1024. / 1024.) as alloc_mb
,convert(decimal(9,3),sum(used_bytes) / 1024. / 1024.) as used_mb
,sum(allocation_count) as [allocs]
INTO #RAM_Consumers
from sys.dm_db_xtp_memory_consumers
group by object_id, xtp_object_id

select
T1.object_id, T1.xtp_object_id ,T2.minor_id, T2.type_desc ,T5.name + '.' + T4.name +
iif(T2.minor_id = 0,'','.' + T3.Name)
as [Table/Column] ,T1.allocs as [Allocations]
,T1.alloc_mb,T1.used_mb
from #RAM_Consumers T1
join sys.memory_optimized_tables_internal_attributes T2 on T2.object_id = T1.object_id and T2.xtp_object_id = T1.xtp_object_id
left outer join sys.columns T3 on T2.object_id = T3.object_id and T2.minor_id > 0 and T2.minor_id = T3.column_id
left outer join sys.tables T4 on T2.object_id = T4.object_id
join sys.schemas T5 on T5.schema_id = T4.schema_id
order by T1.alloc_mb desc

DROP TABLE IF EXISTS #RAM_Consumers