How To Get The Details Of DTU & Vcore Used In Azure Database?

How to get the details of DTU & Vcore used in azure Database and we can scale up or down as per the requirements.

Issue Description: How to get the details of DTU & Vcore used in Azure Database to scale up or down as per the requirements?

Resolution:

  1. Execute the below query in Azure database,

WITH dtu_vcore_map AS

(

SELECT rg.slo_name,

CAST(DATABASEPROPERTYEX(DB_NAME(), 'Edition') AS nvarchar(40)) COLLATE DATABASE_DEFAULT AS dtu_service_tier,

CASE WHEN slo.slo_name LIKE '%SQLG4%' THEN 'Gen4' --Gen4 is retired.

WHEN slo.slo_name LIKE '%SQLGZ%' THEN 'Gen4' --Gen4 is retired.

WHEN slo.slo_name LIKE '%SQLG5%' THEN 'standard_series'

WHEN slo.slo_name LIKE '%SQLG6%' THEN 'standard_series'

WHEN slo.slo_name LIKE '%SQLG7%' THEN 'standard_series'

WHEN slo.slo_name LIKE '%GPGEN8%' THEN 'standard_series'

END COLLATE DATABASE_DEFAULT AS dtu_hardware_gen,

s.scheduler_count * CAST(rg.instance_cap_cpu/100. AS decimal(3,2)) AS dtu_logical_cpus,

CAST((jo.process_memory_limit_mb / s.scheduler_count) / 1024. AS decimal(4,2)) AS dtu_memory_per_core_gb

FROM sys.dm_user_db_resource_governance AS rg

CROSS JOIN (SELECT COUNT(1) AS scheduler_count FROM sys.dm_os_schedulers WHERE status COLLATE DATABASE_DEFAULT = 'VISIBLE ONLINE') AS s

CROSS JOIN sys.dm_os_job_object AS jo

CROSS APPLY (

SELECT UPPER(rg.slo_name) COLLATE DATABASE_DEFAULT AS slo_name

) slo

WHERE rg.dtu_limit > 0

AND

DB_NAME() COLLATE DATABASE_DEFAULT <> 'master'

AND

rg.database_id = DB_ID()

)

SELECT dtu_logical_cpus,

dtu_memory_per_core_gb,

dtu_service_tier,

CASE WHEN dtu_service_tier = 'Basic' THEN 'General Purpose'

WHEN dtu_service_tier = 'Standard' THEN 'General Purpose or Hyperscale'

WHEN dtu_service_tier = 'Premium' THEN 'Business Critical or Hyperscale'

END AS vcore_service_tier,

CASE WHEN dtu_hardware_gen = 'Gen4' THEN dtu_logical_cpus * 1.7

WHEN dtu_hardware_gen = 'standard_series' THEN dtu_logical_cpus

END AS standard_series_vcores,

5.05 AS standard_series_memory_per_core_gb,

CASE WHEN dtu_hardware_gen = 'Gen4' THEN dtu_logical_cpus

WHEN dtu_hardware_gen = 'standard_series' THEN dtu_logical_cpus * 0.8

END AS Fsv2_vcores,

1.89 AS Fsv2_memory_per_core_gb,

CASE WHEN dtu_hardware_gen = 'Gen4' THEN dtu_logical_cpus * 1.4

WHEN dtu_hardware_gen = 'standard_series' THEN dtu_logical_cpus * 0.9

END AS M_vcores,

29.4 AS M_memory_per_core_gb

FROM dtu_vcore_map;

  1. Post executing this query in Azure database, result something like below format.
  2. Now view the current DTU size and if vCore needs to be moved, then migrate as per the below vCore column result. This will help to manage the same as per the current hardware size.

  1. There is serverless option in the vCore and if needed, use this option to manage the billing efficient way.