Search code examples
postgresqlamazon-rdsamazon-aurorapg-notify

LISTEN/NOTIFY on AWS Aurora/postgres


I am hoping to implement a trigger that fires a notify on table change in PostgreSQL, but I am unable to find any definite answer to if it would work in a cluster.

Does PostgreSQL listen/notify work on AWS Aurora (both provisioned and serverless), and can I expect all clients to receive notifications regardless of what instance they are connected to?

If yes, are there any major performance concerns?

Thanks :)


Solution

  • The best AWS Documentation implies - YES, it does work

    Specifically for Aurora Serverless, there is an advisory that "LISTEN/NOTIFY" is NOT RECOMMENDED. This implies that it's possible with Aurora Serverless but not advisable. It also implies that normal RDS LISTEN/NOTIFY does work and is ok to use.

    https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/aurora-serverless.html

    Currently, certain SQL queries and commands, such as cursors with hold (DECLARE name ... CURSOR WITH HOLD FOR query); session-level advisory locks; temporary relations; and asynchronous notifications (LISTEN, NOTIFY commands) prevent scaling and are not recommended

    My own quick test on AWS shows - Yes, it does work

    1. Launch Instance with Public Access

    enter image description here

    ...

    enter image description here

    1. Allow Traffic

    enter image description here

    1. Run command in dbeaver

    enter image description here

    Note: This test doesn't show a successful receipt of a notification. That will need a quick console application to test that.