Modern query engines face the same enemy: the cost of interpreting a query plan value by value. Two schools emerged to fight it. One processes many values at a time in tight loops over arrays. The other compiles the query into machine code so the CPU never interprets it at all. Both can be orders of magnitude faster than a naive interpreter, yet they reach that speed from opposite directions.
Vectorized execution amortises interpretation across a batch of values, while JIT compilation removes interpretation entirely by generating native code, so one improves the loop and the other eliminates it.
The choice shapes how an engine handles diverse data, how quickly it starts a query, and how much engineering it takes to maintain. It is a real design decision in databases that handle billions of rows a day.
Part One: What each engine actually does
A vectorized engine represents intermediate results as arrays, or vectors, of values. Instead of calling a function for one row at a time, it calls a function that processes a batch of a thousand values in a tight loop. That loop is warm in the CPU cache, branch prediction works well, and the per-value overhead of interpreting an expression tree is divided by the batch size. Many operators — filters, projections, aggregations — become simple loops over contiguous memory, which is exactly what modern hardware likes.
A JIT engine treats the query plan as a program to be compiled. It translates expressions and operators into an intermediate representation, optimises them, and emits native machine code tailored to that specific query and the types involved at runtime. The resulting function runs directly on the CPU, with no dispatch per value and no generic type handling. Compilation happens when the query starts, so there is an up-front cost, but long-running queries amortise it away.
One approach keeps a general interpreter and makes it operate in bulk; the other throws away the interpreter for each query. Both attack the same tax.
Part Two: The arithmetic of the trade
Imagine filtering a billion rows on a simple condition. A row-at-a-time interpreter might spend most of its time on function calls and type checks — say, a few dozen nanoseconds per row, which is tens of seconds for a billion rows. A vectorized engine processes a thousand values per call, reducing dispatch overhead by roughly a thousandfold and letting the arithmetic run near memory bandwidth. A JIT engine removes the dispatch entirely, so the loop runs about as fast as hand-written C, often within a small factor of memory speed.
The difference shows up in startup cost. Vectorized engines begin immediately, because there is nothing to compile; this makes them excellent for short, ad-hoc queries where the whole answer arrives in milliseconds. JIT engines pay a compilation cost that may be tens or hundreds of milliseconds, which is invisible on a query that runs for minutes but painful on one that finishes in ten milliseconds. Databases serving interactive dashboards care about that tail latency, which is why many keep a vectorized fast path for short queries.
The data-analytics infrastructure market is worth tens of billions of dollars, and a large part of that value is the difference between a dashboard that returns instantly and one that spins. Query speed is not a vanity metric; it decides whether people explore data or give up.
Vectorized execution wins on short queries and diverse types because it starts instantly, while JIT compilation wins on long, repeated queries because it removes the interpreter altogether.
That is the practical split, and hybrid engines increasingly offer both paths and choose between them at runtime.
Part Three: Where each approach breaks
Vectorized execution breaks when operators do not fit the batch model. Some algorithms — certain joins, recursive traversals, or complex user-defined functions — are awkward to express as loops over arrays, and the engine falls back to slower paths. It also moves large arrays around, which can pressure memory bandwidth and caches; if a query touches wide rows, the vectors get large and the advantage of contiguous processing shrinks.
JIT compilation breaks when compilation dominates. Ad-hoc queries that run once and finish quickly may spend more time generating code than executing it. It also complicates correctness: generating machine code at runtime means a compiler bug becomes a wrong answer, and debugging generated code is harder than debugging an interpreter. Supporting many types and operations multiplies the amount of code the engine must generate and maintain, which is a heavy engineering burden for a small team.
There is a middle ground worth noting. Some engines compile expression-level code into small native fragments while keeping operators vectorized, getting part of both benefits. That hybrid is increasingly common because it matches how real workloads look — mostly simple expressions over large batches, with occasional complex operators.
Part Four: An everyday example
Think of two ways to prepare a large stack of identical forms. A vectorized worker lays out a hundred forms and stamps them in one continuous motion, moving the stamp across the row rather than picking up each sheet separately. There is still a method — the stamping — but the setup cost is shared across a hundred forms. A JIT worker builds a custom stamping machine for this exact form before starting. The machine is faster per sheet, but building it takes time. If there are ten forms, the first worker wins; if there are ten thousand, the second does.
A real office does both: it stamps the small stack by hand and builds the machine for the big run. A query engine that chooses its path by estimated row count is making the same decision.
What is actually transferable
The lesson is that interpretation is a tax you can pay in bulk or eliminate up front, and which you choose depends on how long the work will run. Sharing overhead across a batch is a gentle optimisation that helps almost immediately; compiling away the interpreter is a heavier optimisation that only pays on sustained work. Knowing the shape of your workload — short and many, or long and few — tells you which to invest in.
A second lesson is that performance claims without workload context are nearly meaningless. An engine tuned for long analytical scans can lose badly on a dashboard query, and vice versa. When someone says their engine is faster, ask what queries and what row counts. The honest answer usually reveals a vectorized path, a JIT path, or both — and a set of choices made for good reasons.
Batches and compiled code are not two generations of one idea but two ways of paying the same cost, and a well-designed engine lets the workload decide which bill to pay.
SOL: HCqPmPJM3NVtS6YrmVaTZYnuP8XZ2PFgQZKT94VK1LkS
Creating this takes real effort — thank you for the support.


