DB Internals AtlasPostgreSQL 18.6 Home About

Parameter · Query Tuning / Planner Cost Constants

jit_above_cost

Perform JIT compilation if query is more expensive. -1 disables JIT compilation.

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

In plain words

JIT (just-in-time compilation) turns parts of a query into machine code before running it. Compiling takes time, so it only pays off for long queries. PostgreSQL uses JIT only if the planner's estimated cost is above this value.

For DBAs and operators

After planning, if jit = on, this is not -1, and the plan's total cost is greater than it, the executor compiles expressions (WHERE clauses, projections, aggregates) and, with jit_tuple_deforming, the code that unpacks rows. EXPLAIN ANALYZE then ends with a section like this real one from 18.6:

JIT:
  Functions: 5
  Options: Inlining false, Optimization true, Expressions true, Deforming true
  Timing: Generation 0.241 ms (Deform 0.091 ms), Inlining 0.000 ms,
          Optimization 10.881 ms, Emission 9.177 ms, Total 20.299 ms

Note the JIT section only appears with COSTS on. The classic support case: an OLTP query with a bad estimate crosses 100,000, spends tens of milliseconds or more compiling on every execution, and becomes several times slower than before. Fixes are raising this threshold (for example to 500,000 or more), fixing the estimate, or setting jit = off. Compilation happens per query and per parallel worker and is not cached across executions.

How to change it

Any user can change it for their session with SET.

See it in context

JIT compilation Life of a query

Related parameters

jit jit_inline_above_cost jit_optimize_above_cost jit_expressions jit_tuple_deforming

All Query Tuning parameters