I need to have my trigger to run after the field s updated or to run in background. Since for now as soon as the trigger is fired the UI is blocked until the procedure in the trigger itself is executed. Anyway to make the trigger in such a way that as soon as the field is updated, the UI do not block away.
I have tried:
CREATE CONSTRAINT TRIGGER property_created_simple_prod_trigger
AFTER UPDATE ON properties DEFERRABLE INITIALLY DEFERRED
FOR EACH ROW
EXECUTE PROCEDURE simple_production_materialized_view_procedure_trigger();
But hard luck nothing works.
PostgreSQL doesn't have background procedures/triggers, so you can't do that directly.
What I suggest us having the trigger send a NOTIFY
that your application LISTEN
s to. Have the application's LISTEN
ing thread be a separate connection, managed by a separate thread, that does background processing when it receives notifications.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With