Hands-on Lab·MySQL
MySQL Indexes, Selectivity and Skip Scan
A composite index takes the query from 57.4ms to 20.7ms - a 2.8x improvement, not the 100x the articles promise. And filtering on the index's second column alone still uses it, which contradicts the leftmost-prefix rule as usually taught.
Performance Guide 32 of 45 Advanced
- OSUbuntu 26.04 LTS (resolute)
- MySQL8.4.10-0ubuntu0.26.04.1
- Test data400,000 rows, 2 core / 4 GB host
- TimeAbout 18 min
- Reviewed27 August 2026
Written against the versions above. Skip scan arrived in MySQL 8.0.13. On earlier versions the leftmost-prefix rule holds exactly as usually described, which is why so much advice still says so.
| Server Name | IP Address | OS | Roles | CPU | RAM | HDD |
|---|---|---|---|---|---|---|
| db-a01 | 192.168.0.81 | Ubuntu 26.04 LTS | Primary / Source / Replica Set Member 1 | 2 Core | 4 GB | 50 GB |
Before you start
- The 400,000-row
eventstable from the previous guide.
-
Add the index and read the new plan
-
Measure the improvement honestly
-
The result that contradicts the rule
-
Look at the selectivity behind all of it
Official sources
- MySQL 8.4 Reference Manual - Optimizing Queries with EXPLAIN
- MySQL 8.4 Reference Manual - Obtaining Execution Plan Information
- MySQL 8.4 Reference Manual - Multiple-Column Indexes
- MySQL 8.4 Reference Manual - Skip Scan Range Access
- MySQL 8.4 Reference Manual - The Slow Query Log
- MySQL 8.4 Reference Manual - InnoDB Locking