Plan nodes · Scans

Index Scan

Searches a B-tree (or other index), then fetches each matching row from the table.

Walks the index to the first matching key, then follows each index entry to its row in the heap. Rows come out in index order, which can save a Sort. Each fetch is a random read, so it is best for few rows; for many, a Bitmap Heap Scan or a Seq Scan wins.

What to look for

An Index Scan with many loops under a Nested Loop is the classic plan for a join that looks up a few rows per outer row.

Example

SELECT * FROM tracks WHERE id = 42

1 node

Run with EXPLAIN (ANALYZE, BUFFERS, TIMING OFF, SUMMARY OFF) on the sample database, PostgreSQL 19.0. Open it in the EXPLAIN visualizer →

Related

Seq Scan · Index Only Scan · Bitmap Index Scan · Bitmap Heap Scan · BitmapAnd · BitmapOr · Tid Scan · Tid Range Scan · Sample Scan · Subquery Scan · Function Scan · Table Function Scan · Values Scan · CTE Scan · WorkTable Scan · Named Tuplestore Scan · Foreign Scan · Custom Scan