I understand that TRIGGER
s are useful, as they take care of subsequent queries, but do they have an advantage from performance point of view too?
Replacing two or three queries as
INSERT INTO table1 ...
UPDATE table2 ...
UPDATE table3 ...
with a trigger-based query as
INSERT INTO table 1
with trigger
CREATE TRIGGER test
AFTER INSERT ON table1
FOR EACH ROW BEGIN
UPDATE table2 ... WHERE id=NEW.id;
UPDATE table3 ... WHERE id=NEW.id;
END
Do we still have the same three queries with identical performance? I mean does it matter if we perform the subsequent queries or the
TRIGGER
does?What if we use an API (like conducting queries through PHP). The subsequent queries are internal with no need to connector/driver. Does the
TRIGGER
improve the performance?
Additional Information: The database is mysql 5.5 with innoDB.