postgresql – Postgres, trigger function, is it bad for performance?


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….)