Robins Tharakan: The "Skip Scan" You Already Had Before V18

Robins Tharakan: The "Skip Scan" You Already Had Before V18

Planet PostgreSQL
Planet PostgreSQLFeb 4, 2026

Why It Matters

Skip‑scan can dramatically reduce I/O for queries on non‑leading columns when the leading key has few distinct values, directly affecting latency and cost in production workloads. Understanding when it applies helps DBAs choose indexes that fully exploit PostgreSQL 18’s optimizer improvements.

Key Takeaways

  • PostgreSQL 18 adds native skip‑scan for multicolumn B‑trees.
  • Low‑cardinality leading columns gain up to 5× faster scans.
  • High‑cardinality leading columns see no performance improvement.
  • `Index Searches` >1 in EXPLAIN signals skip‑scan usage.
  • Proper statistics and index choice remain critical across versions.

Pulse Analysis

The skip‑scan addition in PostgreSQL 18 refines how the query planner navigates multicolumn B‑tree structures. Rather than reading every leaf page, the optimizer now isolates each distinct value of the leading column and performs a focused seek on the secondary key. This approach mirrors index‑only scans but reduces unnecessary page reads when the leading column’s cardinality is low, delivering a more efficient execution path without altering the underlying index definition.

Benchmark data underscores the conditional nature of the benefit. In a test where the leading column "bid" had only ten distinct values, the skip‑scan reduced buffer hits from 845 to 39 and lifted transactions per second from roughly 2,500 to 14,400. Conversely, when the leading column "aid" was unique for every row, the planner correctly avoided skip‑scan, as the cost of one million seeks outweighed sequential access. The planner’s cost model, informed by updated statistics, therefore selects the optimal strategy on a case‑by‑case basis.

For practitioners, the practical takeaway is twofold. First, monitor the "Index Searches" metric in EXPLAIN (ANALYZE); a count above one confirms skip‑scan activation. Second, maintain accurate column statistics and consider low‑cardinality leading columns when designing multicolumn indexes, especially for workloads that filter on non‑leading attributes. While older PostgreSQL versions already performed full‑index scans when advantageous, the native skip‑scan in v18 offers a measurable edge for the right data distributions, making it a valuable tool in modern performance‑tuning arsenals.

Robins Tharakan: The "Skip Scan" You Already Had Before v18

Comments

Want to join the conversation?

Loading comments...