# jit

> Allows PostgreSQL to use just-in-time compilation when the build provides a JIT implementation and the plan's estimated cost crosses the configured thresholds. Enabling it does not force JIT for every query.
---

> [!NOTE]
> **Fact — official short description:** “Allow JIT compilation.”

## Identity {#identity}

| Field | Value | Meaning |
| --- | --- | --- |
| Type | `bool` | Upstream pg_settings type |
| Context | `user` | Settable by an ordinary user |
| Unit | — | Raw unit |
| Range | — | Raw limits in the last observed version |
| Enum values | — | — for non-enum types |
| Category | Query Tuning / Other Planner Options | Upstream classification |
| Latest boot value | `off` | off |
{.fields meta="-"}

## Lifecycle {#lifecycle}

| Fact | Value |
| --- | --- |
| First observed | PG11 |
| Present in | PG11–19 Beta 3 |
| Removed in | No |
| Introduction commit | [`432bb9e04da4`](https://git.postgresql.org/gitweb/?p=postgresql.git;a=commit;h=432bb9e04da4d4a1799b1fe7c723b975cb070c43) — Basic JIT provider and error handling infrastructure. |
| Commit date | 2018-03-21 |
| Discussion | [thread 1](https://postgr.es/m/20170901064131.tazjxwus3k2w3ybh@alap3.anarazel.de) |

## Default history {#default-history}

| Versions | Raw `boot_val` | Unit | Human value |
| --- | --- | --- | --- |
| PG11 | `off` | — | off |
| PG12–18 | `on` | — | on |
| PG19 Beta 3 | `off` | — | off |
{.full-width caption="Measured PG9.0–19 Beta 3 boot defaults"}

## How it works {#mechanism}

The jit switch is the top-level gate. When it is on, jit_above_cost decides whether compilation starts, while jit_inline_above_cost and jit_optimize_above_cost govern additional, more expensive compilation work.

JIT is mainly beneficial for long-running CPU-bound queries, often analytical ones. Compilation adds latency, so short statements can become slower if thresholds are lowered too aggressively.

The decision is made at plan time. For a prepared statement using a generic plan, the settings active when that plan is prepared control the decision; EXPLAIN ANALYZE reports whether JIT ran and how much time its phases consumed.

## Tuning advice {#tuning-advice}

> [!TIP]
> **Advice.** These are workload-specific starting points and must be validated with measurements.

| Workload | Guidance |
| --- | --- |
| OLTP | Leave the default thresholds high or disable JIT if compilation latency appears in short-request tails. Test at the statement or role level before changing it cluster-wide. |
| OLAP | Keep it available and benchmark CPU-heavy aggregates, expressions, and scans. Judge total execution time, including generation, inlining, optimization, and emission overhead. |
| Small nodes | On small CPU-constrained systems, JIT often has little benefit for ordinary queries. Keeping it on with conservative thresholds is different from lowering thresholds to force compilation. |
{.full-width}

## Pigsty {#pigsty}

Values use the fixed 8-vCPU, 32-GiB, 100-GiB SSD fixture and render the current Pigsty templates for PG19 Beta 3; this does not assert current Pigsty support for that historical or beta release.

| Template | Effective value | Versus upstream boot | Source expression |
| --- | --- | --- | --- |
| OLTP | Unmodified | — | — |
| OLAP | Unmodified | — | — |
| CRIT | Unmodified | — | — |
| TINY | Unmodified | — | — |
{.full-width}

> [!CAUTION]
> **Advice — pending human review.** Fact from the current Pigsty template projection: OLTP: PG11–19 Beta 3 unmodified; OLAP: PG11–19 Beta 3 unmodified; CRIT: PG11–19 Beta 3 unmodified; TINY: PG11–19 Beta 3 unmodified. No Pigsty-specific rationale is inferred from an absent override.

## Common pitfalls {#common-pitfalls}

- jit=on does nothing if PostgreSQL was built without an available JIT implementation.
- On does not mean every query is compiled; cost thresholds still gate execution.
- Lowering thresholds can make short queries slower than interpreted execution.
- Generic prepared plans use the configuration in effect when the plan was prepared.
- Estimated cost is not execution time, so threshold behavior must be measured with representative plans.

## Related parameters {#related-parameters}

[`jit_above_cost`](/parameters/jit-above-cost/) · [`jit_inline_above_cost`](/parameters/jit-inline-above-cost/) · [`jit_optimize_above_cost`](/parameters/jit-optimize-above-cost/) · [`jit_provider`](/parameters/jit-provider/) · [`plan_cache_mode`](/parameters/plan-cache-mode/) · [`jit_expressions`](/parameters/jit-expressions/)

## References {#references}

- [PostgreSQL 19 Beta 3 — jit](https://www.postgresql.org/docs/19/runtime-config-query.html#GUC-JIT)
- [PostgreSQL 18: When to JIT?](https://www.postgresql.org/docs/18/jit-decision.html)
- [PostgreSQL 18: JIT Configuration](https://www.postgresql.org/docs/18/jit-configuration.html)
- [PostgreSQL 19 release notes](https://www.postgresql.org/docs/19/release-19.html)
- [Machine-readable GUC export](/data/guc.jsonl)
