Firing the Interpreter. A Case Study of LLVM-based Expression Compilation - Just in Time

Dennis Butterstein

PostgreSQL Conference Europe (PGCONF 2016), Tallinn, Estonia, November 2016.

Recent research demonstrates that query compilation has significant advantages over the state of the art interpreted approach.

Some compiling database systems - such as HyPer - have been around some time now. But in fact these systems are not widely deployed yet.

In contrast, PostgreSQL is one of the most widely deployed database engines. To connect recent research in query code generation with one of the most widely deployed database engines, in this talk we will present how just in time compilation of SQL expressions into machine code can be built into PostgreSQL 9:

Our compilation calls on LLVM to translate arithmetic and filter expressions into native x86 instructions just before SQL query execution begins. We deliberately follow a non-invasive design that does not turn PostgreSQL on its head: interpreted and compiled expression evaluation coexist and both are used to execute the same query.

After the presentation of technical details, we will quantify the significant query runtime improvements the approach exhibits and discuss weaknesses and strengths of the approach.