pgrust says its JIT compiles code for every SQL query in 5 microseconds
Michael Malis and Jason Seibel bypassed LLVM with ARM64 stencils, a narrow technical bet that could make JIT useful beyond long analytics jobs.
By RuntimeWire Staff · Published
Primary source: malisper.me
Why it matters
Cutting JIT startup from about 50 milliseconds to 5 microseconds could bring compiled execution to short queries, though pgrust still has to prove correctness and portability.

Michael Malis (@mmalisper) and Jason Seibel (@JasonSeibel) built pgrust, whose JIT compiler generates query-specific machine code in roughly 5 microseconds, according to Malis. That is fast enough for pgrust to compile every SQL query before executing it. Malis detailed the design in an August 2026 technical walkthrough that uses a small regular-expression engine to explain how pgrust avoids the usual compilation delay.
Malis arrived at this experiment after years spent inside production databases. He joined Heap after graduating from high school in 2015 and eventually led work on a PostgreSQL cluster holding about a petabyte of data, according to his Y Combinator profile. He later co-founded Freshpaint, a healthcare data software provider from Y Combinator's Summer 2019 batch. Freshpaint announced a $30M Series B in July 2024, bringing its disclosed funding to $42M.
That operating history shaped pgrust. Malis and Seibel began exploring the PostgreSQL rewrite around April 2026 after repeatedly hearing from startups whose reliability problems traced back to databases, Malis said on an August 14th episode of Postgres FM. The pair saw AI coding agents as a way to revisit architectural choices that a mature database cannot easily replace without breaking existing installations.
The compiler skips LLVM
PostgreSQL already supports JIT compilation through LLVM. Its own documentation says the feature is primarily useful for long-running, CPU-bound queries because compilation overhead can exceed the time saved on short work.
pgrust takes a narrower route. Instead of handing intermediate code to LLVM or generating C or C++ for another compiler, pgrust directly emits ARM64 machine instructions. Its copy-and-patch design starts with small machine-code templates, called stencils, and fills in values such as characters, addresses and branch offsets at runtime. The completed stencils are joined, copied into executable memory and called as a normal function.
The pgrust repository compares its roughly 5-microsecond compilation time with about 50 milliseconds for the LLVM or generated-code path. That is a claimed 10,000-fold reduction in compilation latency. The 5-microsecond figure measures compilation, rather than the time required to execute a query.
Malis's tutorial applies the technique to a deliberately limited regex engine supporting literal strings, concatenation and repetition with the * operator. It leaves out alternation, lookbehind and a parser. In Malis's benchmark, the generated code ran about 12 to 20 times faster than the interpreter and roughly matched code handwritten for the same expression. Those results belong to Malis's demonstration benchmark, rather than an independent database test.
The tutorial's value comes from showing the mechanism in enough detail to reproduce: ARM64 instructions, register assignments, branch calculations, executable-memory setup and the Rust emitter that combines the stencils. Malis writes that his previous assembly experience consisted mainly of completing a security challenge. "I've never actually written assembly myself," he wrote. A coding agent handled much of the instruction-level work after he specified the compiler's structure.
AI changes which systems work get attempted
Malis's wager is that coding agents can lower the fixed cost of specialized systems software. General-purpose compiler infrastructure remains the sensible choice when software must support many processors and operating systems. pgrust can trade portability for compilation speed because Malis expects database workloads to run on a much smaller set of cloud hardware.
That trade is visible in pgrust 0.2. The current JIT targets ARM's Neoverse V2 architecture used by AWS Graviton4. pgrust can run elsewhere, according to its repository, but users should not expect comparable performance. The narrow target lets Malis and Seibel optimize around one instruction set while avoiding the work of maintaining several compiler backends.
The approach also exposes the economics behind the experiment. Malis said on Postgres FM that he had personally funded pgrust using proceeds from selling some of his Freshpaint equity. He also said the spending was becoming difficult to sustain, prompting work on reducing token usage and considering other funding approaches. AI made a PostgreSQL rewrite possible for a tiny group, but the compute bill still places a limit on how long that group can keep expanding the experiment.
pgrust has moved quickly since April. Malis first described building the rewrite with coding agents in an early account of pgrust. By June 25th, pgrust reported passing PostgreSQL's complete default regression suite and its isolation tests. The current repository lists 46,066 passing regression queries and compatibility with PostgreSQL 18.3.
Five microseconds does not make a production database
pgrust's repository explicitly warns users against storing valuable data in the current release. Existing PostgreSQL extensions do not work, the JIT's performance is tied to Graviton4, and pgrust says bugs remain despite passing PostgreSQL's regression suite.
Malis has been direct about the limits of that suite. On Postgres FM, he described passing the regression tests as a low bar because they cover only part of PostgreSQL's code and often verify basic feature behavior rather than every edge case. pgrust is adding differential fuzzing, crash simulation and formal verification against PostgreSQL's C implementation. Its repository says 1,000 of roughly 3,000 user-facing PostgreSQL functions have undergone formal equivalence checks.
The broader performance claims need the same framing as the JIT number. pgrust reports 30% higher throughput than PostgreSQL 18.3 on a 300GB read-only OLTP test and an 18.5% advantage over ClickHouse on the combined ClickBench score. The repository says those runs used Graviton4-tuned builds and notes that a previously reported PostgreSQL advantage above 50% was revised downward after results differed between Kubernetes and bare EC2.
The 5-microsecond compiler is still the cleanest expression of Malis and Seibel's strategy. They are using AI to build narrow, hardware-aware components that established databases struggle to justify across decades of compatibility commitments. The next milestone is operator trust: proving that pgrust can preserve PostgreSQL behavior under concurrency, crashes and real workloads while keeping the speed that made the rewrite worth attempting.