The MapScaping Podcast - GIS, Geospatial, Remote Sensing, earth observation and digital geography · MapScaping

PostgreSQL - Listen and Notify Clients In Real Time

·26 min·2 clips
Discover how PGEventServe, a Postgres SQL event server, could revolutionize real-time geospatial data notifications.
This episode of the MapScaping Podcast features host Daniel and returning guest Paul Ramsey, a core developer of the PostGIS spatial database extension. They discuss Paul's new tool, PGEventServe, which is a specialized event server written in the Go programming language. The conversation focuses on the tool's purpose and its application within geospatial technology workflows. PGEventServe exclusively handles events generated by PostgreSQL's LISTEN/NOTIFY command, passing payloads to waiting WebSocket clients. Paul explains that the tool solves a specific problem in building real-time applications where database changes need to be broadcast instantly. He describes a common architectural pattern where a traditional web server acts as an intermediary between a database and a client. The discussion details how LISTEN and NOTIFY are built-in PostgreSQL commands for sending signals and messages between database sessions. Paul clarifies that PGEventServe is not a general-purpose server but a "single-purpose" bridge for these notifications. He illustrates its utility with a hypothetical mapping application that needs to update all users when new data is inserted. The tool allows developers to avoid constantly polling the database for changes, which is inefficient and resource-intensive. A key insight is that PGEventServe enables a "reactive" system where the database itself can push updates directly to end-user applications. Paul emphasizes that this approach leverages PostgreSQL's existing, robust notification system rather than requiring external message queues like Redis. He notes the tool is particularly useful for geospatial dashboards or collaborative editing tools requiring live data synchronization. The conversation reveals that the entire codebase for PGEventServe is remarkably small, consisting of just a few hundred lines of Go code. Paul argues that its simplicity is its strength, making it easy to understand, deploy, and trust for a critical connectivity function. He positions it as a minimalist solution that fits neatly into a modern, microservices-oriented architecture without adding significant complexity. The tone is highly technical and educational, with a conversational flow between two knowledgeable practitioners. The style is practical and code-focused, aimed at developers and system architects. Listeners interested in PostgreSQL, real-time application design, and efficient geospatial data pipelines will find this episode highly valuable. Those without a background in database development or server-side programming might find the discussion too niche and specialized.
Listen to the show on