Postgres, trigger function, is it bad for performance?

by zumzum   Last Updated August 01, 2020 14:06 PM

I have added the following trigger function to one of my tables in my Postgres database.

CREATE OR REPLACE FUNCTION trigger_set_timestamp()
RETURNS TRIGGER AS $$
BEGIN
  NEW.updated_at = NOW();
  RETURN NEW;
END;
$$ LANGUAGE plpgsql;

I am new to this, so, I am wondering, is this going to slow down my database? Should I avoid trigger functions for performance reasons and if so, what's the alternative?

(In this case this is the only way I knew how to make the updated_at date column always set the date when any of the columns in the table would change....)

Tags : postgresql


Related Questions


Postgres gist slow index f_unaccent

Updated April 09, 2018 20:06 PM