mysql

Plan and review MySQL schema design, indexing, query tuning, and operations.

5|Updated Jan 31, 2026
One-click install
npx skills add https://github.com/nuggocto/dotfiles --skill mysql-nuggocto
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mysql
Source: https://github.com/nuggocto/dotfiles/tree/main/opencode/skills/mysql
Command: npx skills add https://github.com/nuggocto/dotfiles --skill mysql-nuggocto

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Designing and maintaining MySQL/InnoDB databases involves many subtle decisions—primary key selection, composite index ordering, isolation levels, online DDL—that silently cause slow queries, deadlocks, or production outages when done wrong. This Skill provides structured, evidence-based guidance for making safe and measurable MySQL changes. ## Core Features & Use Cases - Schema and Index Design: Guidance on primary keys, data types, character sets, composite and covering indexes, partitioning, and JSON column patterns. - Query and Transaction Tuning: EXPLAIN/EXPLAIN ANALYZE interpretation, N+1 detection, deadlock diagnosis, isolation level selection, and row-locking gotchas. - Operations and Migrations: Online DDL strategies, connection pool sizing, replication lag mitigation, and index maintenance with rollback-aware rollout steps. - Use Case: When a query on a 50M-row orders table is slow, use this Skill to analyze the EXPLAIN plan, design a composite index following the leftmost prefix rule, and roll it out with ALGORITHM=INPLACE plus a rollback plan. ## Quick Start Ask the assistant to review your MySQL table schema and slow query, then propose an index and migration plan using the mysql skill.

Frequently Asked Questions about mysql

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I design a composite index in MySQL?

Order composite index columns with equality predicates first, then range or sort columns, following the leftmost prefix rule. Range predicates stop index usage for subsequent columns, so place them last. Verify usage with EXPLAIN and check key_len to confirm how many columns are used.

How do I diagnose and fix MySQL deadlocks?

Run SHOW ENGINE INNODB STATUS and inspect the LATEST DETECTED DEADLOCK section to see the conflicting transactions. Common causes are opposite row access ordering, gap locks under REPEATABLE READ, and missing indexes on WHERE columns. Fix by indexing filtered columns, keeping transactions short, and retrying error 1213 with backoff.

Should I use UUID or BIGINT as a MySQL primary key?

Prefer BIGINT UNSIGNED AUTO_INCREMENT for write-heavy OLTP tables because InnoDB clusters rows by primary key and sequential inserts avoid page splits. If external IDs are needed, store the UUID as BINARY(16) in a secondary unique column rather than as the clustered primary key.

Does ALTER TABLE lock MySQL tables in production?

It depends on the algorithm: INSTANT is metadata-only, INPLACE rebuilds in the background with brief metadata locks, and COPY blocks writes entirely. Always specify ALGORITHM and LOCK=NONE explicitly so the statement fails loudly instead of silently falling back to a blocking COPY on large tables.

Why is my MySQL query not using its index?

Common causes are functions on indexed columns, implicit type conversions, leading-wildcard LIKE patterns, and OR conditions across different columns. Rewrite predicates to be sargable, such as replacing YEAR(created_at) = 2024 with a range comparison, then confirm with EXPLAIN.

When should I use READ COMMITTED instead of REPEATABLE READ in MySQL?

Stay on the REPEATABLE READ default for general OLTP since it prevents phantoms via next-key locks. Switch to READ COMMITTED per-session only when gap-lock deadlocks are confirmed or during high-contention bulk imports, and never change it globally.