I cant figure out a way to get rid of the sort warning error

mja1175 2014-03-21 22:19:31

I have tried many different ways, many different indexes and statistics, anytime I get the speed up I get a sort warning.

SQLkiwi 2014-03-22 00:17:41
It's hard to offer much in the way of concrete advice based on an anonymized plan alone. Ensure your statistics are up to date, you have created any additional multi-column statistics that might be helpful for cardinality estimation, and any useful indexes are in place. The area where problems first arise is this join:

Plan fragment

Specifically, the number of rows from the scan is slightly off, and the estimated number of rows those rows will join to is substantially incorrect. An additional index might help, as might a filtered index. It rather depends on the data distribution. If it is skewed, it might be hard to provide that information to the optimizer.

You could try materializing the result of the subtree rooted at the hash join, or the join identified above, in a temporary table. This will give the optimizer better information about the size of the data to be sorted.