Wednesday, May 8, 2013

Can I prevent SQL Server from consolidating histogram steps in statistics?

@wBob


Yes, I can theoretically do it with plan guides (as I already mentioned earlier), but I’ll need to do it in each and every query which joins to DimDatum. If that’s the only option, I would rather prefer to create 3000 statistics objects.


@ Gert-Jan Strik


Thank you for the idea with the foreign key constraint. I didn’t consider it because I thought foreign key constraints help only by join elimination. I tried your suggestion and unfortunately it didn’t help.


(created a trusted foreign key constraint ALTERTABLE dbo.FaktMVaR ADD FOREIGN KEY (DatumID) REFERENCES dbo.DimDatum(DatumID)


I’ve uploaded the sample BugHistogramConsolidation database to Skydrive http://sdrv.ms/ZqClF7.


If anybody has any idea how I could cure the problem, please try the sample or just post here.


The sample database has a bit different date ranges. The sample queries are:


GOOD: WHERE dd.DatumID >= 2012111600 AND dd.DatumID < 2012111700


BAD: WHERE dd.DatumID >= 2012111500 AND dd.DatumID < 2012111600


No comments:

Post a Comment