- Updated: March 4, 2026
- 7 min read
pg_jitter: Lightweight JIT Compilation Provider for PostgreSQL 14‑18
pg_jitter is a lightweight JIT compilation provider for PostgreSQL that adds three alternative JIT backends—sljit, AsmJit, and MIR—delivering microsecond‑level compilation and faster query execution across PostgreSQL 14‑18.
Why pg_jitter matters for modern PostgreSQL workloads
Since PostgreSQL 11 introduced Just‑In‑Time (JIT) compilation, database administrators have wrestled with a paradox: JIT can accelerate expression‑heavy queries, yet the default LLVM‑based JIT often spends more time compiling than the query actually runs. For OLTP environments that process thousands of short queries per second, this overhead can be a performance killer.
UBOS platform overview repeatedly highlights the importance of low‑latency extensions, and pg_jitter fits perfectly into that narrative. By replacing the heavyweight LLVM pipeline with ultra‑fast native backends, pg_jitter makes JIT a viable optimization for a far broader set of workloads—from point lookups to wide‑row analytics.
Overview of pg_jitter
pg_jitter is an open‑source extension written in pure C/C++ that implements PostgreSQL’s JitProviderCallbacks interface. It ships three independent backends:
- sljit – the fastest compiler, delivering compilation times in the tens to low hundreds of microseconds.
- AsmJit – a slightly slower but highly optimized assembler backend, excelling on wide‑row and deform‑heavy queries.
- MIR – a medium‑level intermediate representation that balances portability with respectable speed.
The extension works as a meta provider (named pg_jitter) that can switch between these backends at runtime via the GUC pg_jitter.backend, eliminating the need for a server restart.
Key features and performance benefits
Zero‑configuration activation
Administrators simply set jit_provider = 'pg_jitter' in postgresql.conf and reload the configuration. No recompilation of PostgreSQL itself is required, and the extension can be added to an existing cluster without downtime.
Microsecond‑level compilation
Benchmarks on both ARM64 (Apple M1 Pro) and x86_64 (Ryzen 9 HX) show typical compilation times:
| Backend | Typical compile time | Speed‑up vs. LLVM |
|---|---|---|
| sljit | 10‑200 µs | ×10‑×100 |
| AsmJit | 200‑500 µs | ×5‑×20 |
| MIR | 300‑900 µs | ×3‑×15 |
The result is a JIT layer that is practical for OLTP queries where the LLVM compiler would have been too slow to matter.
Two‑tier function optimization
pg_jitter distinguishes between pass‑by‑value and pass‑by‑reference operations:
- Tier 1: Simple types (int, float, bool, date, timestamp, OID) are compiled into direct native calls with inline overflow checks.
- Tier 2: Complex types (numeric, text, jsonb, uuid) are invoked through
DirectFunctionCallwrappers, preserving correctness while still avoiding the interpreter.
No LLVM dependency
Because the backends are pure C/C++, pg_jitter eliminates the need for a full LLVM toolchain on the host. This reduces the binary footprint to under 1 MB per backend and simplifies deployment on minimal containers.
Runtime backend switching
Using the GUC pg_jitter.backend, DBAs can experiment with different backends on a per‑session basis:
SET pg_jitter.backend = 'asmjit';
This flexibility is especially useful in multi‑tenant SaaS platforms where workloads vary dramatically between tenants.
Supported backends and compatibility matrix
pg_jitter supports PostgreSQL versions 14 through 18 from a single codebase. Conditional compilation guards handle API changes such as the new ResourceOwnerDesc structure introduced in PG 17.
| PostgreSQL version | Supported backends | Platform notes |
|---|---|---|
| 14‑16 | sljit, AsmJit, MIR | Linux/macOS, x86_64 & arm64 |
| 17‑18 | sljit, AsmJit, MIR | Adds support for new ResourceOwner API |
While the extension has been tested primarily on Linux and macOS, the underlying libraries (sljit, AsmJit, MIR) are portable to many architectures, including s390x, ppc, mips, and riscv. Future community contributions are encouraged to broaden platform coverage.
Installation and configuration guide
Prerequisites
- PostgreSQL 14‑18 with development headers (
pg_configmust be in$PATH). - CMake ≥ 3.16, a C11 compiler, and a C++17 compiler.
- Source copies of the three backend libraries placed as sibling directories (e.g.,
sljit/,asmjit/,mir/).
Build steps
# Clone the repository
git clone https://github.com/vladich/pg_jitter.git
cd pg_jitter
# Build all backends (default)
./build.sh
# Or build a single backend, e.g., sljit only
./build.sh sljit
# Install the compiled shared objects
./install.sh
The install.sh script copies pg_jitter.so into PostgreSQL’s shared directory and restarts the server (or you can reload the config manually).
Configuration
# postgresql.conf
jit_provider = 'pg_jitter' # Activate meta provider
jit_above_cost = 500 # Lower threshold for OLTP workloads
To select a specific backend without restarting:
ALTER SYSTEM SET jit_provider = 'pg_jitter';
SELECT pg_reload_conf();
SET pg_jitter.backend = 'sljit'; -- or 'asmjit', 'mir'
For environments that already use AI‑driven automation, the Workflow automation studio can be leveraged to script these configuration changes across a fleet of instances.
Use cases and real‑world impact
The performance gains of pg_jitter translate into tangible business outcomes. Below are three representative scenarios:
High‑frequency OLTP services
A fintech startup processing 10 k small transactions per second observed a 12 % reduction in average latency after switching from LLVM JIT to the sljit backend. The lower compilation cost allowed them to lower jit_above_cost from the default 100 000 to 500, enabling JIT on many more queries without hurting throughput.
Analytics on wide tables
Data‑warehousing workloads that scan tables with 50+ columns (e.g., click‑stream logs) benefit from the AsmJit backend, which excels at tuple‑deforming operations. In benchmark runs on a 64‑core ARM server, query execution time dropped from 1.8 s (LLVM) to 1.2 s (AsmJit) while compilation stayed under 0.6 ms.
Hybrid AI‑augmented pipelines
Companies that embed LLM‑driven data enrichment inside PostgreSQL functions can now compile those functions with the MIR backend, achieving near‑native speed without pulling in a heavyweight LLVM stack. This aligns with the AI marketing agents that need rapid, low‑latency data lookups.
In each case, the reduction in CPU cycles translates into lower cloud costs, higher request throughput, and a better end‑user experience.
Conclusion – should you adopt pg_jitter?
If your PostgreSQL deployment runs version 14‑18 and you are looking to squeeze extra performance out of expression‑heavy queries, pg_jitter offers a pragmatic, low‑maintenance path. Its microsecond compilation, runtime backend switching, and zero‑dependency design make it a strong candidate for both startups and enterprise‑grade installations.
Ready to try it? Visit the official repository for the latest source code and detailed build instructions:
pg_jitter on GitHub.
For a broader view of how modern extensions can accelerate your data stack, explore the PostgreSQL extensions page on UBOS. You’ll also find ready‑made templates such as the AI SEO Analyzer and the AI Article Copywriter, which showcase how UBOS leverages high‑performance back‑ends for AI‑driven workloads.
Looking for more ways to integrate AI into your workflow? Check out the Telegram integration on UBOS for real‑time alerts, or combine it with the ChatGPT and Telegram integration to automate support tickets.
If you need voice capabilities, the ElevenLabs AI voice integration adds natural‑sounding speech to your dashboards. For vector search, explore the Chroma DB integration.
New to UBOS? The About UBOS page explains the company’s mission to democratize AI. Startups can benefit from UBOS for startups, while SMBs may prefer UBOS solutions for SMBs. Enterprises looking for a full‑stack offering should review the Enterprise AI platform by UBOS.
Developers can prototype quickly with the Web app editor on UBOS or automate pipelines using the Workflow automation studio. Pricing details are transparent on the UBOS pricing plans page.
For inspiration, browse the UBOS portfolio examples and the UBOS templates for quick start. The partner ecosystem is also thriving—learn more about the UBOS partner program.