Can LISTEN/NOTIFY deal with more than 100 every second? - Mailing list pgsql-general

From Gavin Mu
Subject Can LISTEN/NOTIFY deal with more than 100 every second?
Date
Msg-id 708189661001311738m691300ael4dd0a0b8c85cccd0@mail.gmail.com
Whole thread Raw
Responses Re: Can LISTEN/NOTIFY deal with more than 100 every second?
Re: Can LISTEN/NOTIFY deal with more than 100 every second?
Re: Can LISTEN/NOTIFY deal with more than 100 every second?
List pgsql-general
Hi,

I am prototyping a system which sends all INSERT/UPDATE/DELETE events
to a third party software, I do:

CREATE TABLE data (id Serial PRIMARY KEY, data VARCHAR(255));
CREATE TABLE log (op CHAR(6), id integer, data VARCHAR(255));
CREATE OR REPLACE RULE send_notify AS ON INSERT TO log DO ALSO NOTIFY logevent;
CREATE OR REPLACE FUNCTION log_event() RETURNS TRIGGER AS $$
    BEGIN
        IF (TG_OP = 'DELETE') THEN
            INSERT INTO log VALUES ('DELETE', OLD.id, OLD.data);
        ELSIF (TG_OP = 'UPDATE') THEN
            INSERT INTO log VALUES ('UPDATE', NEW.id, NEW.data);
        ELSIF (TG_OP = 'INSERT') THEN
            INSERT INTO log VALUES ('INSERT', NEW.id, NEW.data);
        END IF;
        RETURN NULL;
    END;
$$ LANGUAGE plpgsql;

CREATE TRIGGER log_event_trigger AFTER INSERT OR UPDATE OR DELETE ON
data FOR EACH ROW EXECUTE PROCEDURE log_event();

A simple client program is used to wait for the NOTIFY logevent and
query the log table to send the changes, then delete what he has sent.

When I inserted data to TABLE data with the rate of about 25 every
second, the client can receive the notifies without any problem, and
when I use 3 similar programs to feed data, which means about 75
events every second, I found that Postgres didn't send NOTIFY
opportunely, since the client do SELECT query every several hundreds
seconds, which is too long to be acceptable.

So what I want to know is, is there anything wrong with my idea? and
how frequence can LISTEN/NOTIFY support? Thanks.

Regards,
Gavin Mu

pgsql-general by date:

Previous
From: ray
Date:
Subject: How to test my new install
Next
From: Jayadevan M
Date:
Subject: Re: how to look for duplicate rows?