What is a covering index, and how do Index Scan, Index Only Scan and Bitmap Heap Scan differ?
Short answer
A covering index holds every column the query needs, so the database answers from the index without reading the table: PostgreSQL shows Index Only Scan, MySQL shows Using index.
3 points to say:
- A covering index answers without reading the table;
SELECT *almost always breaks covering. - PostgreSQL adds covering columns with
INCLUDE; MySQL adds them to the key. - Bitmap scans suit a medium number of rows or combined conditions; high
Heap FetchesmeansVACUUMshould run more often.
Keep reading the deep dive
Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.