WG211/M14Romph
From WG 2.11
Commercial and open source database systems consist of millions of lines of highly optimized C code. Yet, their performance on individual queries falls 10x or 100x short of what a hand-written, specialized, implementation of the same query can achieve.
As a proof of concept and for tutorial purposes, we have developed a SQL to C compiler in 500 lines of Scala. Lightweight Modular Staging (LMS) enabled us to turn a naive relational algebra interpreter into an efficient compiler. This little query engines distills some earlier (and more serious) work which received a best paper award at VLDB.