---
name: "mysql-percona-toolkit-pt-query-digest"
description: "Analyze MySQL slow query logs to detect query anti-patterns, missing indexes, and lock stalls."
metadata:
  author: "Percona"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "analyze mysql slow query log"
  - "run pt-query-digest"
  - "identify query bottlenecks mysql"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Percona pt-query-digest Slow Query Profiling

Parses and aggregates MySQL slow query logs using Percona pt-query-digest: ranking queries by 95th percentile latency, analyzing lock times, row examination ratios, and fingerprinting recurring query templates.

## When to Invoke
Invoke this skill whenever you need to:
- analyze mysql slow query log
- run pt-query-digest
- identify query bottlenecks mysql

## Execution SOP & Rules
1. Enable slow query logging in MySQL with long_query_time = 0.5 and log_queries_not_using_indexes = ON.
2. Execute pt-query-digest /var/log/mysql/mysql-slow.log > slow_query_report.txt.
3. Review the Overall metrics summary for query concurrency, total lock time, and throughput distributions.
4. Take normalized query fingerprints from the top items and inspect their EXPLAIN execution plans.

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
