How to tell if/when Postgres triggers are executing

Viewed 147

I'm working in a legacy codebase/database. The code previously depended on triggers but at one point stopped using them - the logic was moved into the main (Nodejs) codebase and the CREATE TRIGGER statements were removed. Nonetheless, the triggers still exist in the DB. I can see them searching the pg_trigger table: enter image description here

As far as I can tell they're still enabled which is weird because to my knowledge they shouldn't be doing anything. If they're not being used I'd like to remove them. My questions:

  1. Is there way to tell the last time a trigger executed?
  2. Are there any other ways I can figure out if these triggers are even doing anything anymore?
1 Answers

There is no way to do that, unless you modify the triggers to record the execution somewhere.

Perhaps session_replication_role is set to replica. Then normal triggers (tgenabled = 'O') don't fire.

Related