Data flow · EXPLAIN ANALYZE, PostgreSQL 16

Wrapping the column vs rewriting as a range

Wrapping the column vs rewriting as a range A date_part condition wrapped around tao_luc leads to a Seq Scan reading all 200,000 rows and discarding 162,482, taking 29.6 ms, with the planner estimating 1,000 rows against 37,518 actual. A range condition on the bare column leads to a Bitmap Index Scan on idx_don_tao_luc then a Bitmap Heap Scan, taking 5.4 ms, estimating 38,225 rows against 37,518 actual. WHERE CONDITION ACCESS PATH TIME · ROW COUNT Function wraps the columndate_part('year', tao_luc)= 2026 Seq Scan on doncomputes date_part on all 200,000 rowsFilter throws away 162,482 rows 29.6 msest. 1,000 rowsactual 37,518 rows Range on the bare columntao_luc >= '2026-01-01'AND tao_luc < '2027-01-01' Bitmap Index Scanidx_don_tao_lucjumps to the 2026 range Bitmap Heap Scanreads matching pages only37,518 rows 5.4 msest. 38,225 rowsactual 37,518 rows LEGEND Execution plan node Plan that uses the index © tiennhm