I have a problem with a clients database. The statistics does not calculate values that are even clos to the actial rews returned.
Any ideas on how to get some more accurate estimations?
All indexes are up to date.
By MichaelP 16 asked May 26, 2015 at 07:10 AM
Which problem are you looking to solve here? In spite of the somewhat inaccurate cardinality estimation, the plan looks to be a reasonable one. The sort spill is undesirable in general, but it causes few problems here: the overall execution time is only 69ms and the IO_COMPLETION wait associated with the spill is only 1 ms.
The root cause of the mis-estimation is the row goal introduced by the TOP. Essentially, we are asking the optimizer to estimate how many rows it will need to process at each stage of the plan in order to produce 250 rows at the output. This type of estimation is notoriously hard, so mis-estimations are to be expected in many cases.
You could try the documented hint
Another alternative to try is an
You could also declare a variable, say
By SQLkiwi ♦ 6.6k answered May 26, 2015 at 01:19 PM