Download presentation
Presentation is loading. Please wait.
Published byJustine Lumley Modified over 10 years ago
2
Cardinality How many rows? Distribution How many distinct values? density How many rows for each distinct value? Used by optimizer A histogram 200 steps max DBCC SHOWSTATISTICS
3
Index statistics User defined statistics Optimizer created statistics AKA column statistics Filtered FULLSCAN vs SAMPLE Default sampling rate
4
DBCC SHOW_STATISTICS sys.stats view DMF sys.dm_db_stats_properties (object_id, stats_id) modification_counter sys.sysrscols (DAC) sys.system_internals_partition_columns Which stats were actually used by optimizer?
5
UPDATE STATISTICS A single one or all stats on a table WITH FULLSCAN | SAMPLE | STATS_STREAM, ROWCOUNT, PAGECOUNT ALL | COLUMN | INDEX NORECOMPUTE Index rebuild (but not reorganize!) Doesn’t update column statistics FULLSCAN is what you get sp_updatestats Updates all stats in the database where rowmodctr > 0 SAMPLE by default
6
ALTER DATABASE SET AUTO_CREATE_STATISTICS ON SET AUTO_UPDATE_STATISTICS ON SET AUTO_UPDATE_STATISTICS_ASYNC ON Stale statistics during optimization
7
DBCC SHOW_STATISTICS WITH STATS_STREAM SSMS: Database -> Tasks -> Generate Scripts
8
Fullscan vs sample Maintenance plans Ascending keys Stale statistics How many row updates trigger update? Do we really need AUTO_UPDATE and AUTO_CREATE?
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.