CertGrid CertGrid
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

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.

Every command on this page ran on db-a01.
Server NameIP AddressOSRolesCPURAMHDD
db-a01192.168.0.81Ubuntu 26.04 LTSPrimary / Source / Replica Set Member 12 Core4 GB50 GB

Before you start

  1. Add the index and read the new plan

  2. Measure the improvement honestly

  3. The result that contradicts the rule

  4. Look at the selectivity behind all of it

Official sources