DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Query Tuning / Planner Cost Constants

jit_optimize_above_cost

Optimize JIT-compiled functions if query is more expensive. -1 disables optimization.

  • Default: 500000
  • Type: real
  • Range: -1 … 1.79769e+308
  • Applies: Session (any user)

In plain words

Compiled code can be optimized further, which makes it faster but takes longer to produce. PostgreSQL only spends that extra compile time on queries whose estimated cost is above this value.

For DBAs and operators

Without optimization, JIT uses only cheap LLVM passes; above this threshold it runs the more expensive -O3-style pipeline. Like inlining, it only applies once jit_above_cost has triggered JIT. Since the default equals the inline threshold, both usually switch on together.

In the real 18.6 run shown on the jit_above_cost page, optimization took 10.9 ms of a 20.3 ms JIT total, for a query that executed in about 150 ms. For short queries this overhead is pure loss; for multi-second analytical queries it is usually worth it. Setting it to -1 keeps JIT but never optimizes, a middle ground for mixed workloads. The docs note that setting it lower than jit_above_cost is not meaningful (it never applies without JIT), and that setting it higher than jit_inline_above_cost is unlikely to be beneficial.

How to change it

Any user can change it for their session with SET.

See it in context

JIT compilation

Related parameters

jit_above_cost jit_inline_above_cost jit

All Query Tuning parameters