To me, one of the neatest features was the ability to send notifications from triggers:
PERFORM pg_notify("send_sms", <RECORD>::TEXT);
Amazing. PERFORM pg_notify("send_sms", <RECORD>::TEXT);
Amazing.NOTIFY payloads are deduped over the course of a transaction, with a O(n^2) algorithm if all payloads are different.
If you do a NOTIFY on delete or update and hit a few million rows, the query can go from seconds to hours.
The solution would be to write your payloads to a temp table and send them in batch when the transaction ends. Notifying in chunks of 100 will make the process 10'000 faster.