From PL/pgSQL to C: What Are the Optimizations?

PL/pgSQL is an imperative language extension that is implemented as an interpreter layered on-top of PostgreSQL. This introduces friction during execution because for each embedded statement, an executor must be instantiated, run, and finally purged. In our research, we have developed methods to eliminate this problem by Compiling PL/SQL Away, which generates a single SQL query.

In this thesis, we investigate what happens when we compile PL/pgSQL functions into equivalent C functions, thus eliminating the interpretation overhead of the PL/pgSQL interpreter.

This project requires knowledge about C development as well as knowledge of PostgreSQL system internals.


Denis Hirn