Covering Indexes & Index Condition Pushdown (ICP)
Covering Indexes & Index Condition Pushdown (ICP)
Two of the most impactful performance optimizations in modern MySQL database engineering are Covering Indexes and Index Condition Pushdown (ICP). Both drastically slash disk I/O and CPU overhead by resolving queries directly inside the storage engine.
1. Covering Indexes: Zero Double Lookups
A Covering Index is not a special type of index; it is an indexing design pattern where an index contains all the columns requested by a query (SELECT, WHERE, ORDER BY, GROUP BY).
When an index is covering:
- 1InnoDB satisfies the entire query solely by reading the secondary index B+Tree.
- 2It never touches the clustered index or physical table rows!
- 3In
EXPLAINoutput, theExtracolumn displays:Using index.
Now, MySQL reads everything directly from idx_orders_covering, completely bypassing table page lookups!
2. Index Condition Pushdown (ICP)
Prior to MySQL 5.6, when a query had multiple conditions on a composite index where some conditions could not be resolved by tree traversal (e.g., due to a range or wildcard), the storage engine fetched the full row and sent it up to the MySQL Server layer for filtering.
Index Condition Pushdown (ICP) pushes condition evaluation down into the storage engine:
- The storage engine evaluates index columns against query predicates before reading the full table row.
- If the row does not qualify, InnoDB discards it immediately without reading the clustered index!
- In
EXPLAINoutput, theExtracolumn displays:Using index condition.
With ICP:
- 1InnoDB uses
zipcode = '90210'to navigate the index tree. - 2InnoDB inspects
last_name LIKE '%son'directly inside the index leaf before fetching the table row! - 3Only rows matching the pattern cause a clustered index lookup for
address.
Inspecting and Enabling ICP
ICP is enabled by default in MySQL:
Multiple Choice Questions
1. What defines a "Covering Index"?
A. An index that covers every table in the database B. An index that contains all columns requested by a query, allowing execution without touching base table rows C. A primary key that covers all foreign keys D. An index encrypted with SSL Answer: B Explanation: A covering index satisfies the entire query from the index tree alone, avoiding clustered index table lookups entirely.
2. What indicator appears in EXPLAIN's Extra column when a covering index is used?
A. Using temporary B. Using filesort C. Using index D. Using where only Answer: C Explanation: The presence of Using index in the Extra column signifies that the query was resolved entirely within the secondary index structure.
3. What does Index Condition Pushdown (ICP) accomplish?
A. Pushes database updates to client machines B. Evaluates WHERE filter conditions inside the storage engine index layer before fetching base rows C. Automatically compresses index files D. Disables locks during bulk inserts Answer: B Explanation: ICP pushes filtering logic down into the storage engine, drastically reducing the number of times full table rows must be fetched.
4. What appears in EXPLAIN's Extra column when ICP is active for a query?
A. Using index condition B. Using MRR C. Using pushed filter D. Using index only Answer: A Explanation: Using index condition indicates that Index Condition Pushdown is actively filtering candidate rows at the storage engine level.
5. Why do covering indexes dramatically improve high-concurrency read throughput?
A. They convert SQL into C++ binaries B. They reduce buffer pool memory churn and eliminate random I/O from double lookups C. They bypass ACID transaction logs D. They execute queries in parallel threads Answer: B Explanation: Covering indexes avoid the secondary clustered index lookup, drastically lowering disk reads and memory page contention.
Full-Text Search Indexes (MATCH ... AGAINST)
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Related Lessons
| Previous Lesson | Next Lesson |
|---|---|
| Composite Multi-Column Indexes & Leftmost Prefix Rule | Full-Text Search Indexes (MATCH ... AGAINST) |
Practice Quiz
Test your understanding of this lesson with 5 questions. Each question has one correct answer.