P
P
Pier2013-06-17 19:02:59
MySQL
Pier, 2013-06-17 19:02:59

Notification from database?

Good day
I want to contact you with a problem, advise a solution.
You need to receive notifications from the database.
Detailed. Someone (third party) makes inserts (many inserts) into the database. I want to receive messages that someone "inserted" something.
Making selects every second (half, quarter of a second) is not sporty.
I want to ask you what to look at, in which direction to move. Database, some of the popular free ones (Mysql, PostgreSQL)
I've already looked at UDF in MySql and NOTIFY in PostgreSQL. The first option requires additional development, but this is not a problem, you need fast data acquisition.
Thanks everyone!

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
subvillion, 2013-06-17
@subvillion

PostgreSQL has triggers, first CREATE FUNCTION and then CREATE TRIGGER. Respond to insert/update/create.
In mysql, this seems to be more difficult.

L
lightsgoout, 2013-06-17
@lightsgoout

If you need to receive notifications at the application level, then postgresql's listen/notify is a good fit. Starting with version 9.x, you can also send a payload along with a notification.
There may be problems in the libraries through which you work with postgres, for example, I used postgresql odbc in java, but there you have to do select 1 so that the client receives notifications, but, for example, there is no such problem in Python's psycopg2.
If you don’t need to get out of the database, then triggers are suitable, especially since postgres has powerful built-in procedural languages: plpgsql, plperl, where you can even send mail to each insert through sendmail.

1
1x1, 2013-06-18
@1x1

UDF for MySql can be found like this: convert changes to json and send to memcacheq/redis/mongo or a simple udp package. Triggers on the slave to avoid problems when canceling a transaction.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question