Answer the question
In order to leave comments, you need to log in
How to optimize such a trigger in PostgreSQL?
There is a trigger function
CREATE OR REPLACE FUNCTION update()
RETURNS trigger AS $$
BEGIN
NEW.f1 := some_value();
NEW.updated_at := now(); -- now() будет выполняться на каждой строке?
RETURN NEW;
END;
$$ LANGUAGE plpgsql VOLATILE
CREATE TRIGGER tg_update
BEFORE INSERT OR UPDATE
ON my_table
FOR EACH ROW
EXECUTE PROCEDURE update();
Answer the question
In order to leave comments, you need to log in
check TG_OP or make additional trigger
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question