QuestDB includes a JIT compiler which is run on queries (and sub-queries) that perform a full scan over a table or table partitions. The main goal behind this feature is to improve performance for filters with arithmetical expressions. To do so, the JIT compiler emits machine code with a single function that may also use SIMD (vector) instructions.
For details on the implementation, motivation, and internals of this feature, see our article about SQL JIT compilation. This post describes our storage model, how we built a JIT compiler for SQL and our plans for improving it in future.
The JIT compiler is currently a beta feature, and therefore performance may vary as enhancements and improvements are added. For not-yet-implemented functionality, see the known limitations section below.
The types of queries that are eligible for performance improvements via JIT
compilation are those which contain
WHERE clauses. Here are some examples
which are supported based on the
cpu-only data set from the
Time Series Benchmark Suite
The JIT compiler is disabled by default due to the current beta status of this
feature. To enable it, change the
cairo.sql.jit.mode setting in the
server configuration file from
Embedded API users are able to enable the compiler globally by providing their
CairoConfiguration implementation. Alternatively, JIT compilation can be
enabled for a single query by using the
The latter may look like the following:
Server logs should contain references to
SQL JIT compiler mode:
Due to certain limitations noted below, JIT compilation won't take place for all queries. To understand whether JIT compilation took place for a query, one will see something similar in the server logs:
The first implementation of the JIT SQL compiler has a number of limitations:
- Only x86-64 CPUs are currently supported.
- Vectorized filter execution requires AVX2 instruction set.
- Filters with any SQL function, such as
round(), are not supported.
- Filters with any pseudo-function or operator, such as
in()on symbol column, or
betweenon non-designated timestamp column, or
withinon geohash column, are not supported.
- Only the following arithmetic operations are allowed to be present in the
- Only filters with fixed-size columns are supported: BOOLEAN, BYTE, GEOBYTE, SHORT, GEOSHORT, CHAR, INT, GEOINT, STRING, FLOAT, LONG, GEOLONG, DATE, TIMESTAMP, DOUBLE.