Query Store And Dropped Objects

Grant Fritchey gives us a potential nightmare scenario with Query Store:

Along comes our aggressive junior DBA who decides that there are “too many” indexes on the server. No, I don’t know what that means either, but they evidently read it on the internet or something so they drop the index we created before:

1
DROP INDEX TransactionOccurredWhenNCI ON Warehouse.StockItemTransactions;

What now happens to our lovely execution plan and the plan forcing? We’ll take a look at two events in Extended Events, sql_statement_recompile and query_store_plan_forcing_failed. Nothing happens immediately on dropping the index. The plans associated with that object, if any, are marked as invalid in the cache. The next time we call the query it’s going to recompile and we can see the event:

The result is a bit happier than I would have expected; I was looking forward to a “and the world came crashing down” conclusion.

Related Posts

Non-Blocking Aggregations

Daniel Hutmacher tilts at windmills: It’s not entirely uncommon to want to group by a computed expression in an aggregation query. The trouble is, whenever you group by a computed expression, SQL Server considers the ordering of the data to be lost, and this will turn your buttery-smooth Stream Aggregate operation into a Hash Match […]

Read More

When Stream Aggregates Require Sorting

Itzik Ben-Gan continues his series on grouping and aggregation: Let’s try and figure out the costing formula for the Sort operator. Remember, our focus is the estimated cost and scaling because our ultimate goal is to figure out optimization thresholds where the optimizer changes its choices from one strategy to another. The I/O cost estimate […]

Read More

2 Comments

  • Grant Fritchey on 2016-08-16

    I’d say that overall it was a very happy conclusion. It shows good architecture and approach by Microsoft. I really thought we might see a recompile for every execution. That would have been horrifying.

    • Kevin Feasel on 2016-08-16

      Recompilation for each execution would have been terrible, I agree. My first thought when reading your post, though, was that dropping the index would have resulted in every execution of the query failing, sort of like when you have a procedure with an index hint specified.

Comments are closed

Categories

August 2016
MTWTFSS
« Jul Sep »
1234567
891011121314
15161718192021
22232425262728
293031