|
1 | 1 |
|
2 | 2 | -- SQL Server 2025 Diagnostic Information Queries |
3 | 3 | -- Glenn Berry |
4 | | --- Last Modified: September 17, 2025 |
| 4 | +-- Last Modified: November 3, 2025 |
5 | 5 | -- https://glennsqlperformance.com/ |
6 | 6 | -- https://sqlserverperformance.wordpress.com/ |
7 | 7 | -- YouTube: https://bit.ly/2PkoAM1 |
@@ -656,7 +656,7 @@ IF EXISTS (SELECT * WHERE CONVERT(VARCHAR(2), SERVERPROPERTY('ProductMajorVersio |
656 | 656 | EXEC sys.xp_readerrorlog 0, 1, N'CPU vectorization level'; |
657 | 657 | DECLARE @CPUVectorizationLevel NVARCHAR(200) = (SELECT LogText FROM #CPUVectorizationLevel); |
658 | 658 |
|
659 | | - -- Get TF15097 Status |
| 659 | + -- Get TF 15097 Status |
660 | 660 | DROP TABLE IF EXISTS #TraceFlagStatus; |
661 | 661 | CREATE TABLE #TraceFlagStatus |
662 | 662 | (TraceFlag smallint, TFStatus tinyint, TFGlobal tinyint, TFSession tinyint); |
@@ -1001,7 +1001,7 @@ WHERE lu.counter_name LIKE N'Log File(s) Used Size (KB)%' |
1001 | 1001 | AND ls.counter_name LIKE N'Log File(s) Size (KB)%' |
1002 | 1002 | AND ds.counter_name LIKE N'Data File(s) Size (KB)%' |
1003 | 1003 | AND ls.cntr_value > 0 |
1004 | | -ORDER BY db.[name] OPTION (RECOMPILE); |
| 1004 | +ORDER BY db.[name] OPTION (USE HINT ('FORCE_LEGACY_CARDINALITY_ESTIMATION'), LOOP JOIN, RECOMPILE); |
1005 | 1005 | ------ |
1006 | 1006 |
|
1007 | 1007 | -- sys.databases (Transact-SQL) |
@@ -1499,7 +1499,7 @@ CROSS APPLY sys.dm_exec_query_plan(plan_handle) AS qp |
1499 | 1499 | WHERE cp.cacheobjtype = N'Compiled Plan' |
1500 | 1500 | AND cp.objtype IN (N'Adhoc', N'Prepared') |
1501 | 1501 | AND cp.usecounts = 1 |
1502 | | -ORDER BY cp.size_in_bytes DESC, DB_NAME(t.[dbid]) OPTION (RECOMPILE); |
| 1502 | +ORDER BY cp.size_in_bytes DESC, DB_NAME(t.[dbid]) OPTION (USE HINT ('FORCE_LEGACY_CARDINALITY_ESTIMATION'), FORCE ORDER, LOOP JOIN); |
1503 | 1503 | ------ |
1504 | 1504 |
|
1505 | 1505 | -- Gives you the text, type and size of single-use ad-hoc and prepared queries that waste space in the plan cache |
@@ -2232,13 +2232,14 @@ ORDER BY total_worker_time DESC OPTION (RECOMPILE); |
2232 | 2232 | -- https://bit.ly/2q1Q6BM |
2233 | 2233 |
|
2234 | 2234 |
|
2235 | | --- Determine which scalar UDFs are in-lineable (Query 84) (Inlineable UDFs) |
2236 | | -SELECT OBJECT_NAME(m.object_id) AS [Function Name], m.is_inlineable, m.inline_type, |
2237 | | - efs.total_worker_time |
| 2235 | +-- Determine which scalar UDFs are in-lineable (Query 84) (Inlineable UDFs) |
| 2236 | +SELECT OBJECT_NAME(m.object_id) AS [Function Name], m.is_inlineable, |
| 2237 | + m.inline_type, m.is_schema_bound, m.null_on_null_input, |
| 2238 | + efs.total_worker_time, efs.execution_count, efs.cached_time |
2238 | 2239 | FROM sys.sql_modules AS m WITH (NOLOCK) |
2239 | 2240 | LEFT OUTER JOIN sys.dm_exec_function_stats AS efs WITH (NOLOCK) |
2240 | 2241 | ON m.object_id = efs.object_id |
2241 | | -WHERE efs.type_desc = N'SQL_SCALAR_FUNCTION' |
| 2242 | +WHERE efs.[type_desc] = N'SQL_SCALAR_FUNCTION' |
2242 | 2243 | ORDER BY efs.total_worker_time DESC |
2243 | 2244 | OPTION (RECOMPILE); |
2244 | 2245 | ------ |
|
0 commit comments