SteelReed

Search

Search posts, questions…

SQL & Query TuningQuestion 23 / 37

Middle

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.

index has all columnsmissing columns, few rowsmore rowsQueryRead the indexIndex Only Scanno table readIndex Scanjump to table per rowBitmap Heap Scanread table by page

3 points to say:

  1. A covering index answers without reading the table; SELECT * almost always breaks covering.
  2. PostgreSQL adds covering columns with INCLUDE; MySQL adds them to the key.
  3. Bitmap scans suit a medium number of rows or combined conditions; high Heap Fetches means VACUUM should 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.