ecc-mysql-patterns

Reviews MySQL and MariaDB schemas, indexes, queries, transactions, and configuration from supplied evidence.

Updated Apr 18, 2025
One-click install
npx skills add https://github.com/adriancodes/dotfiles --skill ecc-mysql-patterns-adriancodes
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: ecc-mysql-patterns
Source: https://github.com/adriancodes/dotfiles/tree/main/dot_agents/skills/ecc-mysql-patterns
Command: npx skills add https://github.com/adriancodes/dotfiles --skill ecc-mysql-patterns-adriancodes

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Designing and troubleshooting MySQL or MariaDB databases involves subtle decisions around indexing, transactions, connection pools, and replication where mistakes cause slow queries, deadlocks, and stale reads. This Skill provides evidence-backed review guidance for schema design, slow-query investigation, and production configuration without requiring direct database access. ## Core Features & Use Cases - Schema and Index Review: Apply defaults for primary keys, utf8mb4 text, DECIMAL money columns, soft deletes, and composite index ordering, then validate against caller-supplied EXPLAIN plans. - Query and Transaction Patterns: Implement upserts with MySQL/MariaDB-compatible syntax, keyset pagination, JSON generated columns, full-text search, and deadlock-safe transaction ordering with SKIP LOCKED queue claims. - Operations Guidance: Review connection pool settings (SQLAlchemy, mysql2), replication lag risks, least-privilege grants, and InnoDB configuration values as review prompts rather than presets. - Use Case: A developer investigating a slow orders endpoint supplies an EXPLAIN plan and table definition; the Skill identifies a missing composite index on (account_id, status, created_at) and returns the exact CREATE INDEX statement plus a validation plan. ## Quick Start Ask the assistant to review your MySQL table schema, slow query, or migration plan using the ecc-mysql-patterns guidance and paste the relevant SQL or EXPLAIN output.

Frequently Asked Questions about ecc-mysql-patterns

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

FAQPage Schema
How do I design indexes for MySQL queries with multiple filters?▼

Order composite index columns with equality predicates first, then range or sort columns, such as (account_id, status, created_at). Validate the choice against a caller-supplied EXPLAIN plan, watching for type ALL, NULL keys, or Using filesort signals.

How do I write an upsert that works on both MySQL and MariaDB?▼

Use ON DUPLICATE KEY UPDATE with VALUES(col) for MariaDB or mixed fleets, since MySQL deprecates VALUES(col) in favor of row aliases like VALUES (...) AS new. Confirm the engine and version before choosing the row-alias form.

Does SKIP LOCKED work for general transactional reads in MySQL?▼

No. SKIP LOCKED is appropriate only for queue-style worker claims where skipping locked rows is acceptable. It can return an inconsistent view, so it must not replace normal transactional consistency for accounting or integrity-sensitive reads.

Why should I avoid deep OFFSET pagination on large MySQL tables?▼

Deep OFFSET forces the server to scan and discard rows before returning the page, causing linear slowdowns. Keyset pagination using a (created_at, id) cursor with a matching composite index avoids this scan entirely.

When should I not route reads to a MySQL replica?▼

Avoid replica reads for read-your-own-write paths, checkout flows, permission checks, and idempotency-key reads immediately after a write, because replicas can lag. Pin those flows to the primary and monitor replica SQL thread health and lag.