An index scan retrieves matching rows by traversing a PostgreSQL index. A direct predicate on an indexed column can be fast, while applying a function or incompatible cast to that column can force a sequential scan instead. section 2.7
A timestamp predicate that changes the plan
For indexed payment timestamps, `WHERE tstamp = '2023-10-18 03:40:34.000'` produces an `Index Scan`. Rewriting the predicate as `date_trunc('s', tstamp) = '2023-10-18 03:40:34'` produces a `Seq Scan`, because the expression no longer matches the ordinary index. Move the transformation to the comparison value and use a range instead: `tstamp >= '2023-10-18 03:40:34'::timestamptz AND tstamp < '2023-10-18 03:40:34'::timestamptz + INTERVAL '1 s'`.
Use index scans deliberately:
- Select only required columns: selecting indexed columns alone may enable an Index-Only Scan, while additional columns require table reads through an Index Scan. section 2.9


