### Index Scan
![[assets/ex_indexscan.png|256]]
### The Explain Trace
```sql
-- Point lookup by Primary Key
EXPLAIN (ANALYZE, COSTS, BUFFERS, VERBOSE)
SELECT * FROM animals WHERE id = 100;
```
```text
Index Scan using animals_pkey on public.animals (cost=1.29..9.30 rows=1 width=27) (actual time=1.028..1.029 rows=1 loops=1)
Output: id, name, species_id, created_at
Index Cond: (animals.id = 100)
Buffers: shared hit=1 read=2
Planning Time: 2.519 ms
Execution Time: 1.062 ms
```
---
- **Description**: Scans a table using an index.
- **Performance**: High performance for low-selectivity queries (returning few rows).
- **Factors**: Index height, disk I/O for random heap lookups.
- **Cost**: `index cost + cpu_index_tuple_cost * index entries scanned`
![[assets/ex_index_scan.svg|256]]
- **Operates on**: [[Structures/Index|Index]]
- **Workloads**:
- [[Workloads/IO/DataFile/DataFileRead|IO: DataFileRead]]
- [[Workloads/IO/DataFile/DataFilePrefetch|IO: DataFilePrefetch]]
- [[Workloads/LWLock/Buffers/BufferContent|LWLock: BufferContent]]
- [[Workloads/LWLock/Buffers/BufferMapping|LWLock: BufferMapping]]
- [[Workloads/Lock/relation|Lock: relation]]
- [[Workloads/Lock/page|Lock: page]]