Warning: Constant WP_TEMP_DIR already defined in /var/www/html/blogs/glenn/wp-config.php on line 94

Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/blogs/glenn/wp-config.php:94) in /var/www/html/blogs/glenn/wp-includes/feed-rss2-comments.php on line 8
Comments on: SQL Server Diagnostic Information Queries for November 2016 https://www.sqlskills.com/blogs/glenn/sql-server-diagnostic-information-queries-for-november-2016/ Semi-random musings about SQL Server performance Tue, 09 Oct 2018 19:23:54 +0000 hourly 1 https://wordpress.org/?v=6.9.4 By: Glenn Berry https://www.sqlskills.com/blogs/glenn/sql-server-diagnostic-information-queries-for-november-2016/#comment-222397 Tue, 15 Nov 2016 20:41:38 +0000 http://3.209.169.194/blogs/glenn/?p=1115#comment-222397 I have not seen that issue before. Maybe it is because of the CROSS APPLY being evaluated before the DB_ID filters the results down to the current database.

]]>
By: ijeb reitsma https://www.sqlskills.com/blogs/glenn/sql-server-diagnostic-information-queries-for-november-2016/#comment-222124 Fri, 11 Nov 2016 10:57:02 +0000 http://3.209.169.194/blogs/glenn/?p=1115#comment-222124 Hi Glenn,

On one of my servers this query

— Find missing index warnings for cached plans in the current database (Query 55) (Missing Index Warnings)
— Note: This query could take some time on a busy instance
SELECT TOP(25) OBJECT_NAME(objectid) AS [ObjectName],
cp.objtype, cp.usecounts, cp.size_in_bytes, query_plan
FROM sys.dm_exec_cached_plans AS cp WITH (NOLOCK)
CROSS APPLY sys.dm_exec_query_plan(cp.plan_handle) AS qp
WHERE CAST(query_plan AS NVARCHAR(MAX)) LIKE N’%MissingIndex%’
AND dbid = DB_ID()
ORDER BY cp.usecounts DESC OPTION (RECOMPILE);
——

Gives this result:

Msg 942, Level 14, State 4, Line 3
Database ‘xxx’ cannot be opened because it is offline.

(this is a different user database than the current database context)

I can’t see why SQL Server wants to access the other database by looking at the query.

It’s this version of SQL Server 2012 (SP3) – 11.0.6020.0 (X64)

]]>
By: Glenn Berry https://www.sqlskills.com/blogs/glenn/sql-server-diagnostic-information-queries-for-november-2016/#comment-222019 Wed, 09 Nov 2016 14:36:22 +0000 http://3.209.169.194/blogs/glenn/?p=1115#comment-222019 In reply to ijeb reitsma.

Thanks for catching that. I have fixed that now.

]]>
By: ijeb reitsma https://www.sqlskills.com/blogs/glenn/sql-server-diagnostic-information-queries-for-november-2016/#comment-222014 Wed, 09 Nov 2016 14:22:50 +0000 http://3.209.169.194/blogs/glenn/?p=1115#comment-222014 There is a bug in query 60 for SQL Server 2012. Column is_incremental applies to: SQL Server 2014 through SQL Server 2016.

]]>