Database··
MySQL Indexes: From a Slow Query to a Better B+ Tree
Tracing one slow query through execution plans, composite indexes, selectivity, and the tradeoffs behind faster reads.
Indexes are not magic switches. They are data structures with tradeoffs, and the useful habit is learning how a query reaches the rows it needs.
Start with the query
Before adding an index, inspect the filter, sort, join, and selected columns. A composite index should match how the database narrows the search.
Read the execution plan
EXPLAIN helps show whether MySQL is scanning too much data, using the intended index, or paying for extra sorting.
Tradeoffs
Indexes speed up reads but add write cost and storage. The best index is tied to a real access pattern, not just a column that looks important.
Related work and writing
projectSpring Service LabA production-minded Spring Boot service used to practice API design, persistence, caching, security, and operational boundaries.blogRedis Caching Without SurprisesNotes on cache-aside, expiration, hot keys, invalidation, and choosing when a cache truly belongs in the architecture.