Online / 6 & 7 February 2021

schedule

Getting on a hook or PostgreSQL extensibility


PostgreSQL is well-known for its extensibility. One can create their own types, operators, access methods, etc. or use powerful PL/pgSQL language to write functions, extensions, and so on and so on. Everything is thoroughly documented, supported and ready to use. However, there is also a very intimate extensibility layer, which allows external developers to peek right into the PostgreSQL core — hooks. For some reason this topic is not covered enough by official documentation.

First, this talk will focus on which core hooks do exist, which options they provide for potential developers, and which PostgreSQL extensions get use of them to achieve an additional out-of-core functionality.

Next part will show an example of how one can consistently distribute some DDL across multiple PostgreSQL instances. This is based on experience got from Postgres Professional's take on sharded Postgres (first alpha version of shardman extension is available here).

Finally, there will be demonstrated a tricky way to extend CREATE TABLE syntax using PostgreSQL hooks without even touching the core. So one was able to do, e.g.:

CREATE TABLE users (
  id      int not null,
  name    text
) WITH (distributed_by = 'id',
        num_parts = 12,
        colocate_with = 'companies');

Speakers

Photo of Alexey Kondratov Alexey Kondratov

Attachments

Links