Your plan is cached but dm_exec_query_plan returns NULL, Why?

On occasion you might query sys.dm_exec_query_plan with a valid plan_handle and it will return NULL for the query_plan column.  This is despite seeing the plan_handle in sys.dm_exec_query_stats, sys.dm_exec_procedure_stats, or sys.dm_exec_cached_plans.  In this short post I’ll explain how to replicate this behavior and why you might see it. Replicating For this example I’ll be using a […]

Read More

Do you have unused indexes?

Having the proper indexes in place is important for performance; however, on occasion indexes are created that are never used. Unnecessary indexes incur overhead for any DML. Fortunately this is a simple thing to detect. CREATE TABLE #UnusedIndexes (database_name sysname, table_name sysname, index_id int, object_id int, index_name sysname NULL, user_updates bigint, last_user_update datetime, user_seeks bigint, […]

Read More