Databases Reference
In-Depth Information
Avoid FOR EACH ROW in triggers, when possible
Our trigger is declared with the clause
FOR
EACH
ROW
, because it has to be executed once
for each row inserted or updated in the
LOANS
table.
There are situations where it's enough to execute the trigger once for each insert or
update operation, regardless of the rows affected.
In such situations, it's better to declare the trigger without the
FOR
EACH
ROW
clause,
avoiding unnecessary execution of the trigger for each row interested in the operation,
reducing the execution time.
See also
F
See the recipe
Reducing the number of requests to the database using
materialized views
in
Chapter 2
,
Optimizing Application Design