MySQL
Write correct MySQL queries avoiding common pitfalls with character sets, indexes, and locking.
New
Join 0+ developers using this skill
skill
Data & Analytics
intermediate
Write correct MySQL queries avoiding common pitfalls with character sets, indexes, and locking.
Real data. Real impact.
Emerging
Developers
Per week
Open source
Skills give you superpowers. Install in 30 seconds.
| Topic | File |
|---|---|
| Index design deep dive | |
| Transactions and locking | |
| Query optimization | |
| Production config | |
utf8 is broken—only 3 bytes, can't store emoji; always use utf8mb4utf8mb4_unicode_ci for case-insensitive sorting; utf8mb4_bin for exact byte comparisonSET NAMES utf8mb4 or connection string parameterWHERE active = true in index definitionINDEX (description(100))—without length, errorINDEX (a, b, c) to cover cINSERT ... ON DUPLICATE KEY UPDATE—not standard SQL; needs unique key conflictLAST_INSERT_ID() for auto-increment—no RETURNING clause like PostgreSQLREPLACE INTO deletes then inserts—changes auto-increment ID, triggers DELETE cascadeSELECT ... FOR UPDATE locks rows—but gap locks may lock more than expectedinnodb_lock_wait_timeout for adjustmentFOR UPDATE SKIP LOCKED exists in MySQL 8+—queue patternsql_mode includes ONLY_FULL_GROUP_BY by default in MySQL 5.7+ANY_VALUE(column) to silence error when you know values are sameSHOW TABLE STATUS—convert with ALTER TABLE ... ENGINE=InnoDBLIMIT offset, count different order than PostgreSQL's LIMIT count OFFSET offset!= and <> both work; prefer <> for SQL standardALTER TABLE commits immediately, can't rollbackTINYINT(1)—TRUE/FALSE are just 1/0IFNULL(a, b) instead of COALESCE for two args—though COALESCE workswait_timeout kills idle connections—default 8 hours; pooler may not noticemax_connections default 151—often too low; each uses memorySHOW PROCESSLIST to see active connections—kill long-running with KILL <id>Seconds_Behind_Master before relying on replica readsEXPLAIN ANALYZE only in MySQL 8.0.18+—older versions just EXPLAIN without actual timesOPTIMIZE TABLE for fragmented tables—locks table; use pt-online-schema-change for big tablesinnodb_buffer_pool_size—set to 70-80% of RAM for dedicated DB serverNo automatic installation available. Please visit the source repository for installation instructions.
View Installation Instructions1,500+ AI skills, agents & workflows. Install in 30 seconds. Part of the Torly.ai family.
© 2026 Torly.ai. All rights reserved.