forked from vincent/notebook
28 lines
913 B
MySQL
28 lines
913 B
MySQL
|
-- diagnostic des index fragment<6E>s
|
|||
|
SELECT * FROM sys.dm_db_index_physical_stats(NULL, NULL, NULL, NULL, NULL)
|
|||
|
WHERE avg_fragmentation_in_percent > 10
|
|||
|
AND page_count>64
|
|||
|
|
|||
|
-- ALTER INDEX .... REORGANIZE --> pas bloquant mais pas top
|
|||
|
-- ALTER INDEX .... REBUILD --> bloquant mais top (peut <20>tre non bloquant si ed. Enterprise et mode ONLINE)
|
|||
|
|
|||
|
-- diagnostic des index inutilis<69>s
|
|||
|
-- !!!!!!!!!!!!!!!!!!!!!!!!! ATTENTION : ne pas utiliser si moins de 30 jours de fonctionnement CONTINU du SGBDR
|
|||
|
SELECT sqlserver_start_time FROM sys.dm_os_sys_info
|
|||
|
|
|||
|
SELECT *
|
|||
|
FROM sys.dm_db_index_usage_stats
|
|||
|
WHERE index_id > 1
|
|||
|
ORDER BY user_seeks, user_lookups, user_scans, user_updates DESC
|
|||
|
|
|||
|
-- recalcul des statistiques
|
|||
|
SELECT *
|
|||
|
FROM sys.stats AS s
|
|||
|
CROSS APPLY sys.dm_db_stats_properties(s.object_id, s.stats_id)
|
|||
|
WHERE modification_counter > rows / 10
|
|||
|
|
|||
|
UPDATE STATISTICS .... WITH FULLSCAN
|
|||
|
|
|||
|
|
|||
|
|