Covering Index in SQL Explained with Examples

A covering index holds every column the query needs, so the table is never read. How to spot "Using index" in EXPLAIN, and when covering stops working.

In this chapter

A covering index skips the table, until it does not

Covering indexes: common questions

What is a covering index?

An index that contains every column a query reads, so the database answers from the index alone without visiting the table.

More on Indexes: how queries use them

Keep learning

Overview

Using index Every needed column came from the index. No table access at all (a covering index). Using index condition ICP: part of the WHERE was tested on the index entry before fetching the row. The row is still fetched for matches. Using where The server layer filters rows after the engine returned them. Says nothing about covering by itself. Covered, but not all conditions could be used to seek: remaining ones are checked on index entries. Nothing special: the index narrowed the rows and every match needs a table fetch. chapters · indexes A covering index skips the table, until it does not A query is covered when everything it asks for is already inside the index, so the engine never opens the table. This chapter shows what that saves, the small ways a covering index quietly stops covering, and how index condition pushdown helps when covering is not possible.

1. Is this query covered?

Three habits break coverage silently. SELECT * asks for every column, including the big text one. A new column added to the select list later is not in the index. And a column used only in WHERE still counts: if the index lacks it, the engine needs the row to test it. The price of coverage is size: every added column makes each entry bigger, so the index is slower to cache and every write to those columns touches it. A good fit is a table that links two others, such as product_categories (product_id, category_id). Its queries look up one id and read the other, so an index on both columns answers them without touching the table. Index it in both orders if you also look up from the other side.

2. The prefix index trap

Pick the length from the data, not by habit: count distinct prefixes against distinct whole values (SELECT COUNT(DISTINCT LEFT(email, 10)) / COUNT(DISTINCT email)) and take the shortest length whose ratio is close to 1. If you need covering, either index the whole column or select a different column.

3. When you cannot cover: index condition pushdown

ICP does not reduce index reads, it only prevents wasted table reads. It works on secondary indexes only (a clustered-index row is already the whole row), only for conditions on columns inside the index, and it is a good fallback, not a design goal. The fix that removes both costs is a better index shape or coverage.

Reference: reading Extra

What the Extra column says about the table access PostgreSQL has INCLUDE columns for the same purpose (CREATE INDEX ... (a) INCLUDE (b)) and shows Index Only Scan, with the extra twist that it must still check the visibility map to be sure a row is visible. The EXPLAIN basics are in reading EXPLAIN.

Recap

Covered means every column in SELECT and WHERE is in the index. In InnoDB the primary key is always there too. EXPLAIN says Using index. Each non-covered match costs a random back-to-table lookup into the clustered index. SELECT *, a newly added column, or a filter column missing from the index all break coverage. A prefix index can never cover its column and cannot serve ORDER BY. Choose its length from distinct counts. ICP (Using index condition) tests index-resident conditions before the row fetch. It saves table reads, not index reads, and is weaker than coverage. Covering costs index size and write work. Use it for hot, narrow queries.

More courses

  • Jobs, linked to lessons — Browse jobs where every requirement links to the chapter that teaches it. See how ready you are, how long the gap takes to close, and which listings look stale.
  • Match a job post to courses — Paste a job post. Each skill is matched to a track here and put in learning order, foundations first.
  • React patterns from open source — Patterns extracted from Material UI, Radix, React Aria, React Hook Form, Redux Toolkit, TanStack, and Next.js — not slides about hooks.
  • System Design — Core concepts first (SQL vs NoSQL, CAP, indexing, replication, sharding), then designs grouped by what carries them: the database, Redis, Kafka, or many services.
  • NestJS: build a real API — One ticket-booking API, built in order: a plain Node server first, then NestJS modules, validation, a real database, and the features real clients lean on.
  • Microservices — Microservice patterns one diagram at a time: how to split a monolith, how services talk, and how data stays consistent without distributed transactions.
  • Kafka — A beginner-to-senior path through event logs, reliable delivery, production operations, and disaster recovery.
  • AI engineering for software engineers — Eight free reads, in order, for software engineers moving into AI: when to build an agent, how to build one, how to test it, and how the model works underneath.
  • Frontend system design — How a UI is sliced when it is a product, not a page: ownership of state, cache, routes, and what happens when the network lies.
  • TypeScript in depth — The type system as a design tool. Inference, narrowing, generics, and the errors that mean the model is wrong — not a catalog of utility types.
  • CSS in depth — See the box, then the page. Visual chapters from the box model through Flexbox surprises, Grid, selectors, and units, then backgrounds, shapes, and visual effects, each with a playground.
  • Accessibility — Foundations first (WCAG in plain words, semantic HTML, lists, alt text), then hands-on HTML labs, a full pass of WAI-ARIA 1.3, and a final fix-the-page challenge.
  • Docker — What an image is, why layers cache, and how containers find each other on a network.
  • Redis — Fifteen Redis patterns, one picture each: cache, session, lock, counter, rate limiter, queue, and when Redis is the wrong tool.
  • Kubernetes — Kubernetes from zero to operators: why it exists, Pods, Deployments and Services, then configuration, networking, storage, scheduling, scaling and security.
  • AWS — AWS networking in plain English. A VPC is a gated housing society: streets are subnets, the Internet Gateway is the main gate, and a route table is the signboard.
  • Networking: the NetRoute game — NetRoute is a packet logistics game. You wire up computers, switches, routers, firewalls and gateways, set each device, and watch glowing packets travel. If a packet gets dropped, the game shows you which header field was wrong.