RUS  ENG
Full version
JOURNALS // Proceedings of the Institute for System Programming of the RAS // Archive

Proceedings of ISP RAS, 2016 Volume 28, Issue 4, Pages 217–240 (Mi tisp62)

This article is cited in 5 papers

Dynamic compilation of expressions in SQL queries for PostgreSQL

E. Yu. Sharygina, R. A. Buchatskiya, L. V. Skvortsovb, R. A. Zhuykova, D. M. Melnika

a Institute for System Programming of the Russian Academy of Sciences
b Lomonosov Moscow State University, CMC Department

Abstract: In recent years, as performance and capacity of main and external memory grow, performance of database management systems (DBMSes) on certain kinds of queries is more determined by raw CPU speed. Currently, PostgreSQL uses the interpreter to execute SQL queries. This yields an overhead caused by indirect calls to handler functions and runtime checks, which could be avoided if the query were compiled into native code "on-the-fly", i.e. just-in-time (JIT) compiled: at run time the specific table structure is known as well as data types and built-in functions used in the query as well as the query itself. This is especially important for complex queries, performance of which is CPU-bound. We've developed a PostgreSQL extension that implements SQL query JIT compilation using LLVM compiler infrastructure. In this paper we show how to implement JIT compilation to speed up sequential scan operator (SeqScan) as well as expressions in WHERE clauses. We describe some important optimizations that are possible only with dynamic compilation, such as precomputing tuple attributes offsets only for attributes used by the query. We also discuss the maintainability of our extension, i.e. the automation for translating PostgreSQL backend functions into LLVM IR, using the same source code both for our JIT compiler and the existing interpreter. Currently, with LLVM JIT we achieve up to 5x speedup on synthetic tests as compared to original PostgreSQL interpreter.

Keywords: PostgreSQL, LLVM, dynamic compilation, just-in-time compilation, database management system engines, query languages.

DOI: 10.15514/ISPRAS-2016-28(4)-13



Bibliographic databases:


© Steklov Math. Inst. of RAS, 2024