本文へスキップ
Skillpedia
データベース9.5k · #12278

detect_fragmented_tables

できること

このスキルは、未使用の領域を抱えるMySQLやMariaDBの表を探し、回収できる量を見積もります。ストレージ使用量を安全に減らしたいデータベース管理者向けです。

使う場面

  • ✓データベースのディスクがいっぱいになってきて、無駄がどこにあるか知りたいとき。
  • ✓表に、回収できそうな空き領域が多いとき。
  • ✓メンテナンスを計画しており、サーバーに影響の大きい表を知りたいとき。

スキルのリンク

https://github.com/major/MySQLTuner-perl/blob/master/.agent/skills/detect-fragmented-tables/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/major/MySQLTuner-perl/blob/master/.agent/skills/detect-fragmented-tables/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“データベースの中で最も多くのディスク容量を無駄にしている表を見つけ、どの表なら安全にクリーンアップできるか教えてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

エージェントは表のサイズ情報を読み、各表の空き領域の割合を計算して順位を付けます。クリーンアップのコマンドを提案し、大きな表は影響が大きいとして印を付け、計画を立てやすくします。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

AI Skill: Table Fragmentation & Storage Reclaim Diagnostics

🧠 Purpose & Operational Objectives

The detect_fragmented_tables skill enables autonomous DBA agents to identify wasted disk space, high data file fragmentation, and unused allocated extents across InnoDB and MyISAM tables.

📋 Preconditions & Context

  • Server running MySQL 5.5+ or MariaDB 10.0+.
  • Read access to information_schema.TABLES.
  • Evaluates non-system schemas (skips mysql, information_schema, performance_schema, sys).

🛠️ Input Parameters

Parameter Type Required Default Description
min_fragmentation_pct number No 20 Minimum fragmentation percentage (0-100) to trigger reporting.
min_table_size_mb number No 10 Minimum table size in MB to filter out trivial tables.
schema_filter string No "" Optional schema name to restrict the scan.

📊 Fragmentation Formula & Impact Scoring

$$\text{Total Allocated Space} = \text{DATA_LENGTH} + \text{INDEX_LENGTH} + \text{DATA_FREE}$$ $$\text{Fragmentation Pct} = \left(\frac{\text{DATA_FREE}}{\text{Total Allocated Space}}\right) \times 100$$

  • Tables $< 5\text{GB}$: Can be defragmented online during low-traffic windows via OPTIMIZE TABLE \db`.`table`;`.
  • Tables $\ge 5\text{GB}$: Flagged as is_high_impact: true. Advise using online tools like pt-online-schema-change or gh-ost to prevent extended table locks and disk thrashing.

🛡️ Guardrails & Safety

  • All schema and table names are safely escaped with backticks to prevent SQL injection.
  • Reclaimable disk space is calculated deterministically.
よくある質問

勝手に表をクリーンアップしますか?

いいえ。報告し、コマンドを提案するだけです。データベースで何かを実行する前に、あなたが確認します。

どの表はスキャンしませんか?

mysql、information_schema、performance_schema、sysなどのシステムスキーマはスキャンされません。

スキャンを絞り込めますか?

はい。断片化率の最小値と表サイズを設定したり、1つのスキーマだけにスキャンを限定したりできます。

詳細

作者による元の説明

Detects tables with high storage fragmentation, calculates reclaimable disk space, evaluates lock impact, and generates safe defragmentation commands.

repo: major/MySQLTuner-perl

人気

GitHubのスター
9.5k
ランキング
#12278
ライセンス
GPL-3.0
更新日
2026/10/28

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル