DELAPARRA
Index
Color
NL
Category: SQL

covering index

Explained by Updated

What is covering index?

covering index: An index that contains every column a query needs, so the database answers from the index alone — an index-only scan. A covering index contains every column a query needs. The database can answer the query from the index alone, without looking up the full rows in the table. This is called an index-only scan, and it is often much faster.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about covering index

How is covering index used in practice?

If a page lists a customer's orders with only the date, status and total, an index on (customer_id, created_at) that also includes status and total covers the query completely. PostgreSQL has an INCLUDE clause for those extra columns; in MySQL you add them to the index itself.

What should you keep in mind with covering index?

Use this for frequent, performance-critical queries, not for everything. Wider indexes take more space and slow down writes. Selecting only the columns you need, instead of SELECT *, is what makes covering indexes possible in the first place.

What does an example of covering index look like?

CREATE INDEX idx_cover ON orders (user_id) INCLUDE (total, status);

At a glance

CategorySQL
Explained by
Updated

More SQL terms

All terms starting with C

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.