What is a Covering Index?

The concept of "covering indexes" explained in under 100 words. #Under100

What is a Covering Index?

In a typical index, the database uses the index to look up the primary key, which it then uses to look up the row in the original table.  Two lookups.

If you only need a small subset of fields, you can save a lookup by creating a compound index that includes those fields.

An index is considered a covering index in the context of a SELECT statement that requires only the "covered" fields.  Thus, the CityName, Country index covers the following SQL statement:

SELECT CityName, Country
FROM City
WHERE CityName = 'Berlin'

Bottom Line

A covering index saves a lookup.


Image by esudroff from Pixabay

All original code samples by Mike Wolfe are licensed under CC BY 4.0