Answer the question
In order to leave comments, you need to log in
Why can SELECT slow down after some time, only rebuilding helps rebuilding the index?
There is an Orders table. In which there are now about 5 million records.
There are a lot of fields, indexes. Specifically, the RegistrationTime datetime field. It created the IX_RegistrationTime index with DESC sorting.
After some time, about 1 week, the request starts to fall by timeout, for 2 minutes it does not receive data. If this index is recreated (it takes about 3 minutes to recreate, WITH ONLINE=OFF), then the query starts to run in seconds (from 2 to 10 seconds). And before the re-creation, I looked at the SQL report on the physical statistics of the index, then this index did not have any recommended operation, neither rebuild nor reorganize.
Why this can happen, where to dig?
Answer the question
In order to leave comments, you need to log in
Dig in the direction of checking the query plan, see how the optimizer decided to execute your query during "fast" work and during "slow" work
As far as I remember, you need to update statistics regularly.
Here is a suitable database maintenance script.
I suspect that it's not the index itself. The easiest thing to try is to specify option (recompile) in the request
Well, now the same garbage. The request runs for 1 minute, I cancel it.
Updating statistics only indexes did not help.
After updating statistics on columns - the request began to be normally fulfilled.
Here is 99% of the entire request here. And I don’t know yet if it’s possible to somehow optimize the query here.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question