> **Index Scan** > <table> > <tr> > <td width="25%"><img src="assets/ex_indexscan.png"></td> > <td>A targeted lookup that first traverses an index structure to find specific Tuple IDs (TIDs) matching the filter. It then performs random I/O to fetch those specific rows from the table heap. Efficient for high-selectivity queries where only a small percentage of the table is needed.</td> > </tr> > </table> > > ```sql > -- Point lookup by Primary Key > EXPLAIN (ANALYZE, COSTS, BUFFERS, VERBOSE) > SELECT * FROM animals WHERE id = 100; > ``` > > ![IndexScan Plan Tree](assets/plan_tree_op_index_scan.svg) > > <!-- literal-explain-plan > Captured EXPLAIN provenance for the adjacent reader-facing visual plan. > Canonical capture metadata lives in scratch/actual_operation_plans.json. > > Index Scan using animals_pkey on public.animals (cost=0.29..8.30 rows=1 width=27) (actual time=0.005..0.006 rows=1 loops=1) > Output: id, name, species_id, created_at > Index Cond: (animals.id = 100) > Buffers: shared hit=3 > Planning: > Buffers: shared hit=83 > Planning Time: 0.253 ms > Execution Time: 0.024 ms > --> > > > <!-- > Raw-capture provenance — separate run. > SQL, setup, dataset, settings, and scope: artifacts/chapter4_capture_matrix.json. > Target: PostgreSQL 18.x companion fixture. Cache state: uncontrolled. > Boundary: pg_wait_tracer backend execution root; client states are included when the chart shows them. > Fidelity: exact pg_wait_tracer export. Not the adjacent EXPLAIN run; compare state shape, not durations. > --> > > ![Index Scan separate raw capture](assets/trace_op_index_scan.svg) > > <table> > <tr> > <td rowspan="2" width="25%"><img src="assets/ex_index_scan.svg"></td> > <td><b>Performance</b></td><td>High performance for low-selectivity queries (returning few rows).</td> > </tr> > <tr><td><b>Cost</b></td><td><code>index cost + cpu_index_tuple_cost * index entries scanned</code></td></tr> > </table>