Partitioned table scan without pruning exhausts fast path locks
warningperformanceUpdated Jul 30, 2025
Technologies:
How to detect:
Querying all partitions of a partitioned table without partition pruning acquires locks on each partition and its indexes. With 12 partitions each having an index, a simple SELECT acquires 26 locks (12 partitions + 12 indexes + 1 parent table + 1 parent index), exceeding the 16-slot fast path limit and causing 10 locks to migrate to slow path.
Recommended action:
Implement partition pruning by including partition key columns (e.g., order_ts) in WHERE clauses with constant values. Use PL/pgSQL with EXECUTE format() to inject runtime values as constants, enabling the query planner to prune partitions at planning time. Monitor pg_locks view to verify fastpath='t' for all acquired locks.