Sibedge's contribution to the development of Postgres: a simple installation of PLV8 by Alexey Fadeev

PLV8 ENG (Blog).jpgAt the recent PGConf 2022 conference, Alexey Fadeev, leading Sibedge .NET-developer and Postgres evangelist shared with the community a tool for simplified installation of the PLV8 extension, which we believe will contribute to the development of the professional community. He also spoke in detail about the work on the tool and how such results were achieved.

Postgres is a non-commercial extensible open-source DBMS. One of its extensions is the PLV8, a procedural language based on the V8 engine that allows you to write stored functions in JavaScript inside a database. We have been using this solution in our projects for a year now, and we have seen in practice that it greatly simplifies development for several tasks. PLV8 is very underestimated by developers, and the main reason for its low popularity is the complexity of its build, which requires skill, a lot of Internet traffic, and space for temporary files.

At some point, we decided to build PLV8 ourselves, deliver the assembly to our customers and publish it in the public domain. At first, we just posted the binary files on GitHub. Using the Strip utility, the size of the collected SO-file was reduced by 5 times — from 152 MB to 33 MB. We didn't stop there and made a Postgres Docker image with the PLV8 already installed based on the Debian distribution. We also wanted to reduce the Docker image, for this, we decided to build our PLV8 for the Alpine distribution. It required some hard work, as we were pioneers.

The fact is, that the assembly from the source code is done using a utility from Google that is incompatible with Alpine. However, we found a useful repository with a Docker file to build a V8 engine. This file helped us a lot, as a result, the PLV8 extension was successfully assembled for Alpine and launched. The image decreased from 154 MB to 85.8 MB. To compare, the size of a "pure" Postgres without PLV8 is 77 MB.

As a result, we created a public Docker image of Postgres with the PLV8 and provided an easy installation for any user. We were the first in the world to build the PLV8 extension for the Alpine distribution. In two months, our image was downloaded from DockerHub more than 1000 times.

We are proud that Sibedge engineers speak at international conferences, contribute to the development of professional communities, and help colleagues from other companies improve development efficiency, saving a business time and money! You can download our images for free using this link and use them without any restrictions.

Docker commands to download:
Default version: docker pull sibedge/postgres-plv8
BigInt serialized version: docker pull sibedge/postgres-plv8-bigint

Docker files: