简体   繁体   中英

How to tell if/when Postgres triggers are executing

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: 在此处输入图像描述

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM