Hi guys,
I've filed a Connect Bug under https://connect.microsoft.com/SQLServer/feedback/details/785478/cardinality-estimates-are-wrong-when-using-a-range-condition-in-where-and-matching-value-is-in-the-range-rows-of-the-histogram-bucket#details. Please, vote if you agree that this SQL Server behavior is absolutely unacceptable :)
Concerning the workarounds you suggested:
1. "add dummy rows to DimDatum"
Unfortunately not acceptable for me. I'll gladly make metadata changes (statistics, indexes, even changing the surrogate key DimDatumID), but the data itself may not be changed. Also, I don't think this will help for sure - I have no idea what the exact logic for consolidation of histograms is.
2. "create filtered stats"
Well, to be sure I'll need to create a filtered statistics object for each day (so no consolidation can potentially take place). Unfortunately statistics for individual values (of DatumIDs) don't help the query (see the Connect Bug). So I'll need to provide filtered statistics matching my WHERE-Condition (not good, but possible)
3. "refactor to create a surrogate key for the datumId"
I'm first trying the solution with filtered stats (less invasive). I've tried the change on the data provided here (by me and Gert), and indeed cannot reproduce the problem anymore. I have no idea whether this have some solid explanation or whether it will break the day after tomorrow with slightly different data. If you have any explanation to this behavior - please, post.
Thanks again for patience and help.
No comments:
Post a Comment