sqlsql-serversql-server-2012table-statisticsfiltered-statistics

dropping filtered statistics causes deadlocks


We have a large data warehouse database where we continuously get new rows inserted in 5 different tables, at the left(Edit: right)-hand side of the b-tree (=at end of the table)

This means that ordinary statistics very quickly gets outdated, regarding the new data. So we've changed our insert procedure to also do a CREATE STATISTICS FST_xxx with a WHERE clause that covers the latest two million rows.

This has ensured that we do not get incorrect execution plans. Now we are stranded with hundreds of these. We have a cleanup job that runs once a day that will drop unneeded statistics.

but this causes a lot of Deadlocks.

Is there a way to disable Filtered Statistics or to drop Filtered Statistics without causing deadlocks?

(edit:) The table is clustered on a Bigint Identity(1,1) asending.


Solution

  • Can you clarify where the rows are getting inserted? You said left-hand side of the b-tree, but you also said end of the table. Is it correct to assume this a clustered index you're talking about? And whether it's clustered or not, is the index key ascending? Thanks.