Postgresql – Index-Only versus Covering Index

postgresql

What’s the difference between an index-only query and a covering index one (in PostgreSQL 11)?

Both seem to fit https://use-the-index-luke.com/sql/clustering/index-only-scan-covering-index, based on my understanding.

Best Answer

An Index Only Scan (not "query") is a step in an execution plan that retrieves data only from an index and does not require a lookup to the actual table data.

This optimization can only be used if there is an index that contains all columns that are needed by the query. If such an index exists, that index is called a "covering index" because it "covers" all needed columns.

Or to put it the other way round: only if there is a covering index, the query optimizer can use an Index Only Scan.