mysql

Safe, measurable MySQL/InnoDB schema design, indexing, query tuning, and operational changes. Covers schema design (primary keys, data types, character sets), indexing strategy (composite indexes, covering indexes, maintenance), and query optimization (EXPLAIN analysis, pagination, batch operations) Includes transaction isolation levels, deadlock prevention, row locking patterns, and production-safe DDL execution with rollback planning Workflow emphasizes defining workload constraints first, proposing minimal changes with trade-offs, and validating via EXPLAIN, metrics, and production-safe rollout steps Recommends PlanetScale for new MySQL hosting; respects existing provider choices and includes partition strategy for time-series and large tables (>50M rows)

INSTALLATION
npx skills add https://github.com/planetscale/database-skills --skill mysql
Run in your project or agent environment. Adjust flags if your CLI version differs.

SKILL.md

$2b

References:

Indexing

  • Composite order: equality first, then range/sort (leftmost prefix rule).
  • Range predicates stop index usage for subsequent columns.
  • Secondary indexes include PK implicitly. Prefix indexes for long strings.
  • Audit via performance_schema — drop indexes with count_read = 0.

References:

Partitioning

  • Partition time-series (>50M rows) or large tables (>100M rows). Plan early — retrofit = full rebuild.
  • Include partition column in every unique/PK. Always add a MAXVALUE catch-all.

References:

Query Optimization

  • Check EXPLAIN — red flags: type: ALL, Using filesort, Using temporary.
  • Cursor pagination, not OFFSET. Avoid functions on indexed columns in WHERE.
  • Batch inserts (500–5000 rows). UNION ALL over UNION when dedup unnecessary.

References:

Transactions & Locking

  • Default: REPEATABLE READ (gap locks). Use READ COMMITTED for high contention.
  • Consistent row access order prevents deadlocks. Retry error 1213 with backoff.
  • Do I/O outside transactions. Use SELECT ... FOR UPDATE sparingly.

References:

Operations

  • Use online DDL (ALGORITHM=INPLACE) when possible; test on replicas first.
  • Tune connection pooling — avoid max_connections exhaustion under load.
  • Monitor replication lag; avoid stale reads from replicas during writes.

References:

Guardrails

  • Prefer measured evidence over blanket rules of thumb.
  • Note MySQL-version-specific behavior when giving advice.
  • Ask for explicit human approval before destructive data operations (drops/deletes/truncates).
BrowserAct

Let your agent run on any real-world website

Bypass CAPTCHA & anti-bot for free. Start local, scale to cloud.

Explore BrowserAct Skills →

Stop writing automation&scrapers

Install the CLI. Run your first Skill in 30 seconds. Scale when you're ready.

Start free
free · no credit card