Home
%3CLINGO-SUB%20id%3D%22lingo-sub-738655%22%20slang%3D%22en-US%22%3ELesson%20Learned%20%2394%3A%20What%20is%20the%20TempDB%20configuration%20for%20Azure%20SQL%20Database%20and%20Managed%20Instance%3F%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-738655%22%20slang%3D%22en-US%22%3E%3CP%3EToday%2C%20I%20worked%20on%20a%20service%20request%20that%20our%20customer%20asked%20about%20the%20tempdb%20configuration%20in%20Azure%20SQL%20Database%20and%20Managed%20Instance%20and%20if%20we%20could%20have%20any%20type%20of%20contention%20in%20tempdb.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20terms%20of%20the%20TempDB%20configuration%2C%20you%20could%20see%20this%20configuration%20if%20you%20are%20using%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EAzure%20SQL%20Database%20you%20could%20execute%3A%26nbsp%3B%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3ESELECT%20*%20FROM%20SYS.dm_io_virtual_file_stats(2%2Cnull)%20A%20INNER%20JOIN%20TEMPDB.sys.database_files%20B%20ON%20A.file_id%20%3D%20B.FILE_ID%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CSTRONG%3EAzure%20SQL%20Managed%20Instance%26nbsp%3Byou%20could%20execute%3A%26nbsp%3B%3C%2FSTRONG%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CPRE%3ESELECT%20files.physical_name%2C%20files.name%2C%20stats.num_of_writes%2C%0A(1.0*stats.io_stall_write_ms%2Fstats.num_of_writes)%20AS%20avg_write_stall_ms%2C%0Astats.num_of_reads%2C%0A(1.0*stats.io_stall_read_ms%2Fstats.num_of_reads)%20as%20avg_read_stall_ms%0AFROM%20sys.dm_io_virtual_file_stats(2%2C%20NULL)%20as%20stats%0AINNER%20JOIN%20master.sys.master_files%20AS%20files%0AON%20stats.database_id%20%3D%20files.database_id%0AAND%20stats.file_id%20%3D%20files.file_id%0AWHERE%20files.type_desc%20%3D%20'ROWS'%0A%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EIn%20another%20hand%2C%20in%20terms%20of%20the%20TempDB%20contention%2C%20if%20you%20want%20to%20test%20either%20Azure%20SQL%20Database%20or%20Azure%20SQL%20Managed%20Instance%2C%20basically%20downloading%20the%20file%20%3CA%20href%3D%22https%3A%2F%2Fwww.microsoft.com%2Fen-us%2Fdownload%2Fdetails.aspx%3Fid%3D4511%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Eostress.exe%3C%2FA%3E%20and%20run%2C%20for%20example%2C%20this%20example%3A%3C%2FP%3E%0A%3CP%3E%22C%3A%5CProgram%20Files%5CMicrosoft%20Corporation%5CRMLUtils%5Costress.exe%22%20-Syourservername.database.windows.net%20-Uusername%20-PPassword%20-ddatabasename%20-Q%22SELECT%20TOP%20(5000)%20*%20INTO%20%23t%20FROM%20dbo.AnyTable%3B%20DROP%20TABLE%20%23t%3B%22%20-n100%20-r30%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ESo%2C%20depending%20on%20the%20TEMPDB%20capacity%20based%20on%20your%20database%20tier%20or%20Azure%20SQL%20Managed%20instance%20tier%2C%20you%20could%20try%20to%20reproduce%20contention.%20But%2C%20let%20me%20mention%20that%20Azure%20SQL%20Database%20and%20Managed%20Instance%20has%20already%20configure%20internally%20the%20trace%20flag%201117%20AND%201118.%3C%2FLI%3E%0A%3CLI%3EAlso%2C%20for%20Azure%20SQL%20Managed%20Instance%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2FDataCAT%2FReal-time-performance-monitoring-for-Azure-SQL-Database-Managed%2Fba-p%2F305537%22%20target%3D%22_self%22%3Ereview%3C%2FA%3E%20this%20article%20about%20performance%20monitoring.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EFinally%2C%20I%20found%20that%20we%20have%20more%20information%20available%20for%20both%20model%20of%20databases%20based%20on%20the%20DMV%3A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fes-es%2Fsql%2Frelational-databases%2Fsystem-dynamic-management-views%2Fsys-dm-os-performance-counters-transact-sql%3Fview%3Dsql-server-2017%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Esys.dm_os_performance_counters%3C%2FA%3E%26nbsp%3Bto%20review%20temporal%20tables%20created.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20style%3D%22width%3A%20615px%3B%20height%3A%2077px%3B%22%3Eselect%20%20*%0Afrom%20sys.dm_os_performance_counters%20%0Awhere%20counter_name%20like%20'%25temp%25'%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EEnjoy!%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-738655%22%20slang%3D%22en-US%22%3E%3CP%3EToday%2C%20I%20worked%20on%20a%20service%20request%20that%20our%20customer%20asked%20about%20the%20tempdb%20configuration%20in%20Azure%20SQL%20Database%20and%20Managed%20Instance%20and%20if%20we%20could%20have%20any%20type%20of%20contention%20in%20tempdb.%3C%2FP%3E%3C%2FLINGO-TEASER%3E

Today, I worked on a service request that our customer asked about the tempdb configuration in Azure SQL Database and Managed Instance and if we could have any type of contention in tempdb.

 

In terms of the TempDB configuration, you could see this configuration if you are using:

 

  • Azure SQL Database you could execute: 
SELECT * FROM SYS.dm_io_virtual_file_stats(2,null) A INNER JOIN TEMPDB.sys.database_files B ON A.file_id = B.FILE_ID

 

  • Azure SQL Managed Instance you could execute: 
SELECT files.physical_name, files.name, stats.num_of_writes,
(1.0*stats.io_stall_write_ms/stats.num_of_writes) AS avg_write_stall_ms,
stats.num_of_reads,
(1.0*stats.io_stall_read_ms/stats.num_of_reads) as avg_read_stall_ms
FROM sys.dm_io_virtual_file_stats(2, NULL) as stats
INNER JOIN master.sys.master_files AS files
ON stats.database_id = files.database_id
AND stats.file_id = files.file_id
WHERE files.type_desc = 'ROWS'

 

In another hand, in terms of the TempDB contention, if you want to test either Azure SQL Database or Azure SQL Managed Instance, basically downloading the file ostress.exe and run, for example, this example:

"C:\Program Files\Microsoft Corporation\RMLUtils\ostress.exe" -Syourservername.database.windows.net -Uusername -PPassword -ddatabasename -Q"SELECT TOP (5000) * INTO #t FROM dbo.AnyTable; DROP TABLE #t;" -n100 -r30

 

  • So, depending on the TEMPDB capacity based on your database tier or Azure SQL Managed instance tier, you could try to reproduce contention. But, let me mention that Azure SQL Database and Managed Instance has already configure internally the trace flag 1117 AND 1118.
  • Also, for Azure SQL Managed Instance review this article about performance monitoring.

 

Finally, I found that we have more information available for both model of databases based on the DMV: sys.dm_os_performance_counters to review temporal tables created.

 

select  *
from sys.dm_os_performance_counters 
where counter_name like '%temp%'

 

Enjoy!