Rethinking PostgreSQL Shared Memory for Flexibility and Elasticity
October 20–23
PostgreSQL’s shared memory system has traditionally relied on static allocation at server startup, with a two-stage request process that differs between extensions and core subsystems. While robust, this model limits flexibility, complicates extension development, and often requires restarts to load extensions that require even small portion of the shared memory.
In this talk, we present recent improvements to PostgreSQL’s shared memory infrastructure, including the new ShmemRequestStruct and ShmemRequestHash APIs. These APIs unify shared structure requests into a single step which is same for both the core subsystems and extensions. They also enable shared memory allocation beyond the early startup phase, avoiding server restarts when loading extensions.
These changes form the foundation for an elastic shared memory model paving the way for resizable shared memory structures, which can grow and shrink at runtime while consuming only the memory they actually require. This work, in turn, becomes a key building block for future work, including the ability to resize shared buffers without requiring a server restart. A long-standing limitation in PostgreSQL is about to be lifted.
You will learn how to use the new shared memory APIs to simplify extensions. You will get a sneak peek into the APIs of resizable shared structures and shared buffers from the co-author himself.