Developing PostgreSQL Extensions in C: Hooks, Shared Memory & Best Practices
summary
Shows a concrete extension called vacuum_booster that hooks the executor, allocates a shared-memory “global brain” (prototype tracks 1,000 tables), and spawns a background monitor that creates dynamic workers to proactively vacuum tables once a per-table bloat threshold triggers. Implements registration via _PG_init and shared_preload_libraries, ships control/.sql/.c and a Makefile, uses LWLocks for protection, validates OIDs, makes workers signal-aware, and logs with elog; demonstration claims successful cleanup by dynamic workers and complements autovacuum.
AI-written summary · about
chapters (12)
- 0:00Introduction to PostgreSQL extensions
- 3:34Why use PostgreSQL extensions
- 8:49Extension architecture and structure
- 13:01Vacuum booster extension design
- 21:06Implementing the control file
- 22:30Creating the SQL interface
- 23:31Hooking into PostgreSQL internals
- 26:00Shared memory and background workers
- 27:41Executor flow inspection
- 28:44Monitoring and cleanup workers
- 31:09Best practices for extension development
- 34:12Q&A and summary
related talks
19mVacuuming Enhancements in PostgreSQL 18: Faster, Smarter, More Predictable
42mPostgreSQL Extensions: A Deep Dive
50mSolving PostgreSQL Wicked Problems
45mEnhancing PostgreSQL Plasticity: New Frontiers in Memory Management
28mBeyond Postgres: Insights about the PostgreSQL Extensibility
01h 00mTaking advantage of custom background workers
52mThe trouble with extensions
27mMaintaining Large Tables in PostgreSQL
