diff --git a/HowtoMySQL/Troubleshooting.md b/HowtoMySQL/Troubleshooting.md index aef82a20..2ef19b1b 100644 --- a/HowtoMySQL/Troubleshooting.md +++ b/HowtoMySQL/Troubleshooting.md @@ -842,4 +842,10 @@ On peux égelement calculer le ratio d'espace non utilisé sur une table, exempl On calcule le ratio de cette manière, (30 + 27) = 57 ; 29/57 = 0.5 -C'est à dire que la table contient 50% d'espace vide. \ No newline at end of file +C'est à dire que la table contient 50% d'espace vide. + +Voici une requêtes SQL qui indique également le ratio de fragmentation de chaque tables : + +~~~ +SELECT ENGINE, concat(TABLE_SCHEMA, '.', TABLE_NAME) as table_name, round(DATA_LENGTH/1024/1024, 2) as data_length, round(INDEX_LENGTH/1024/1024, 2) as index_length, round(DATA_FREE/1024/1024, 2) as data_free, (data_free/(index_length+data_length)) as frag_ratio FROM information_schema.tables WHERE DATA_FREE > 0 ORDER BY frag_ratio DESC; +~~~ \ No newline at end of file