select open change scope Open full search

PG.CENTER connects PostgreSQL documentation, reference, and ecosystem knowledge. Maintained by Pigsty.

CONFIGURATION / QUERY TUNING

jit_above_cost

Read PG 18 manual ↗

Sets the query cost above which JIT compilation is activated, if enabled (see Chapter 30).

Type
real
Context
user
Measured default
100000
Unit
Metadata snapshot
18

Definition PG 18 manual

Sets the query cost above which JIT compilation is activated, if enabled (see Chapter 30). Performing JIT costs planning time but can accelerate query execution. Setting this to -1 disables JIT compilation. The default is 100000.

Measured default history
Version intervalDefault
11 – 19100000
Analysis & operational context

Authored guidance from the GUC source snapshot; the version-specific manual above is the definition reference. View source ↗

How it works

jit_above_cost compares the finished plan's estimated cost with a threshold to decide whether PostgreSQL may start JIT compilation. The cost is the planner's arbitrary estimate, not milliseconds.

The decision occurs at plan time and only matters when JIT is enabled and a provider is available. Generic prepared plans retain the decision made when the generic plan was generated.

A value of -1 disables this stage. jit_inline_above_cost and jit_optimize_above_cost are additional gates after jit_above_cost, so setting either below the base compilation threshold is not meaningful. Its user context permits session- or transaction-local changes; newly performed or newly planned work sees the value.

Operational considerations

Reading the threshold as milliseconds rather than arbitrary planner cost units.

Ignoring JIT generation, inlining, optimization, and emission time when benchmarking.

Expecting a changed value to alter a generic plan that was already generated.

Setting an advanced-stage threshold below jit_above_cost and expecting that stage to run by itself.

Workload guidance

OLAP: For long CPU-bound queries, benchmark total elapsed time on both sides of jit_above_cost. Lowering the threshold is useful only when saved execution CPU consistently exceeds compilation overhead.

OLTP: Do not lower jit_above_cost globally to chase a single CPU-heavy statement. Compilation latency is visible in short-query tails; test at statement or role scope and include JIT generation time in the result.

SMALL: Keep the default or disable the stage with -1 when LLVM work competes with a small CPU budget. Estimated cost alone does not prove that JIT will pay back its startup cost.

Version history 4
  1. PG 16 → 17changed
  2. PG 13 → 14changed
  3. PG 11 → 12changed
  4. PG 10 → 11added

Related entries

Further reading

Definition snapshot: english-manuals:683effd33cd154ddfdbfaa1042f… · English manual source