I am in process of developing an MFC based Windows based application, using PostgreSQL which would perform
- Fetches information from the UI
- Performs some logic and store related information to the database
- The stored information has to be send immediately OR at schedule interval (ex. at 5:00 on xyz date) over the network
Currently, we have developed a dispacher mechanism (thread ), which constantly polls the database for new information inserted in the database. The thread fetches the information and send to the network module.
But, I feel this is not the correct approach as
- Polling every time is a overhead. There can be times when there is nothing to execute
- It is not real time , because we poll after every 5 seconds
So
-
Is there a way to send a trigger to my network module as soon as information is updated in database?
-
Or any better way to achieve this task?
Thanks in advance.
Yes you are right @RDX, you shouldnt poll it every time rather you could write a trigger in Postgres and from that trigger try calling a java program which could be seen in the below thread.
Calling java pgm from Postgres trigger