Invisible Indexes — Complete Guide
Invisible Indexes — Complete Guide: free step-by-step lesson with examples, common mistakes, and interview tips — part of MySQL Tutorial on Toolliyo Academy.
On this page
MySQL Tutorial · Lesson 74 of 100
Invisible Indexes
Basics ✓ → Advanced
Advanced · 2 — Production · ~10 min · MySQL — Advanced MySQL
What is this?
Invisible indexes exist for optimizer statistics and testing but are ignored by planner unless session use_invisible_indexes=ON. Lets you test drop impact safely.
Why should you care?
Drop wrong index on orders — production slows overnight. Make invisible first, watch slow log, then drop.
See it live — copy this example
Run in MySQL Workbench or the mysql CLI.
ALTER TABLE orders ALTER INDEX idx_orders_customer INVISIBLE;
EXPLAIN SELECT * FROM orders WHERE customer_id = 5;
-- Plan may skip idx_orders_customer
ALTER TABLE orders ALTER INDEX idx_orders_customer VISIBLE;
What happened?
- INVISIBLE hides index from default plans.
- If queries slow, index was still needed — make VISIBLE again.
- Safer than DROP in prod experimentation.
Practice next
- CREATE or pick existing secondary index.
- ALTER INDEX INVISIBLE.
- EXPLAIN key queries — note plan change.
- SET SESSION use_invisible_indexes = ON to force use for experiments.
- Query performance_schema for index usage stats.
Remember
Test index removal without DROP. Toggle VISIBLE/INVISIBLE quickly. Monitor slow log during invisible window.
DataFlow index retirement
DBA makes legacy idx invisible during sale week — no regressions → drop later.
Outcome: Write throughput gains without read surprise.
Interview prep for this lesson
Practice these questions aloud after reading—each links to a full structured answer.
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!