Why not polling?
Polling wastes requests and still feels slow. WebSockets keep one connection open and push events instantly.
The approach
- Authenticate the socket with the first message.
- Publish events only after the transaction commits.
- Fan out across workers with Postgres LISTEN/NOTIFY.
await conn.execute("SELECT pg_notify($1, $2)", channel, payload)The result: notifications arrive in milliseconds.



