16.20 - When to Use Statement Triggers - Teradata Database - Teradata Vantage NewSQL Engine

Teradata Vantage™ SQL Data Definition Language Detailed Topics

Teradata Database
Teradata Vantage NewSQL Engine
Release Number
March 2019
Content Type
Programming Reference
Publication ID
English (United States)

Statement triggers are often a better choice than row triggers for multirow operations like an INSERT ... SELECT statement because their triggered action is executed only once, while the triggered action for a row trigger is executed once per each qualifying row of the transition table, which can impact performance negatively.

The WHEN condition is tested only once in statement triggers, and it might access information from OLD TABLE or NEW TABLE columns as well as columns from the triggering table.

Because the WHEN condition must provide a single result, aggregation is a typical use for OLD TABLE and NEW TABLE column references.

Although statement triggers fire only once, the join conditions created by WHEN conditions can have a performance impact. Note that specifying an OLD_NEW_TABLE reference, which is valid only for UPDATE AFTER statement triggers, eliminates a join operation and often eliminates the need for WHERE clause filtering conditions.