All skills
planetscale avatar

/mysql

@51f2d4b official

Plan and review MySQL/InnoDB schema, indexing, query tuning, transactions, and operations. Use when creating or modifying MySQL tables, indexes, or queries; diagnosing slow/locking behavior; planning migrations; or troubleshooting replication and connection issues. Load when using a MySQL database.

Use this Skill: https://skilld.dev/gh/planetscale/database-skills/mysql

This session only. Nothing lands on disk.

referencescovering-indexes.md

≈500 tokens on demand. Your agent reads this file only when SKILL.md points to it.

Covering Indexes

A covering index contains all columns a query needs — InnoDB satisfies it from the index alone (Using index in EXPLAIN Extra).

-- Query: SELECT user_id, status, total FROM orders WHERE user_id = 42
-- Covering index (filter columns first, then included columns):
CREATE INDEX idx_orders_cover ON orders (user_id, status, total);

InnoDB Implicit Covering

Because InnoDB secondary indexes store the primary key value with each index entry, INDEX(status) already covers SELECT id FROM t WHERE status = ? (where id is the PK).

ICP vs Covering Index

  • ICP (Using index condition): engine filters at the index level before accessing table rows, but still requires table lookups.
  • Covering index (Using index): query is satisfied entirely from the index, with no table lookups.

EXPLAIN Signals

Look for Using index in the Extra column:

EXPLAIN SELECT user_id, status, total FROM orders WHERE user_id = 42;
-- Extra: Using index ✓

If you see Using index condition instead, the index is helping but not covering — you may need to add selected columns to the index.

When to Use

  • High-frequency reads selecting few columns from wide tables.
  • Not worth it for: wide result sets (TEXT/BLOB), write-heavy tables, low-frequency queries.

Tradeoffs

  • Write amplification: every INSERT/UPDATE/DELETE must update all relevant indexes.
  • Index size: wide indexes consume more disk and buffer pool memory.
  • Maintenance: larger indexes take longer to rebuild during ALTER TABLE.

Guidelines

  • Add columns to existing indexes rather than creating new ones.
  • Order: filter columns first, then additional covered columns.
  • Verify Using index appears in EXPLAIN after adding the index.
  • Pitfall: SELECT * defeats covering indexes — select only the columns you need.

Source: SKILL.md on GitHub

1 alert17d5 checks · Risk SAFE
  • Gen Agent Trust Hub17d

    This skill provides a comprehensive technical reference for MySQL and InnoDB database management, including schema design, indexing, and query optimization. It is authored by PlanetScale and contains no security risks.

  • Socket17d

    No alerts

  • Snyk17d

    Risk: LOW · No issues

  • Runlayer6mo

    7/19 files flagged

  • ZeroLeaks5mo

    Score: 93/100 · 2 sections analyzed

Signed by skilld at 51f2d4b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Activeupdated 7 months ago
  • mysql
  • innodb
  • schema-design
  • indexing
  • query-optimization
  • transactions
  • locking
  • planetscale
  • ddl
  • replication

README badge

README badge for planetscale/database-skills/mysql

Advises on MySQL/InnoDB schema design, indexing strategy, query optimization, transactions, and operational safety. Use when creating tables, tuning slow queries, planning migrations, diagnosing lock contention, or managing replication — includes EXPLAIN analysis guidance and online DDL patterns for production changes.

Generated from the current SKILL.md.

Does this skill work with PlanetScale?
Yes. The skill recommends PlanetScale as the primary hosting choice for new MySQL databases and includes references to PlanetScale-specific features like online DDL.
What MySQL versions does this cover?
The skill applies to MySQL/InnoDB broadly and notes MySQL-version-specific behavior when relevant, but does not lock to a single version.
Does this skill help with query optimization?
Yes. It covers EXPLAIN analysis, pagination patterns, batch inserts, and common pitfalls like N+1 queries and filesort warnings.
Can this skill help with schema migrations?
Yes. It addresses online DDL, partitioning retrofit costs, and production-safe rollout steps including rollback and verification.
Does this cover replication and high availability?
Partially. The skill addresses replication lag monitoring and connection management, but is not a full replication setup guide.

Generated from the current SKILL.md. These answers refresh after source changes.