> For the complete documentation index, see [llms.txt](https://docs.postgresql.tw/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.postgresql.tw/the-sql-language/functions/functions-trigger.md).

# 9.29. Trigger Functions \#

While many uses of triggers involve user-written trigger functions, PostgreSQL provides a few built-in trigger functions that can be used directly in user-defined triggers. These are summarized in [Table 9.110](#BUILTIN-TRIGGERS-TABLE). (Additional built-in trigger functions exist, which implement foreign key constraints and deferred index constraints. Those are not documented here since users need not use them directly.)

For more information about creating triggers, see [CREATE TRIGGER](/reference/sql-commands/sql-createtrigger.md).

**Table 9.110. Built-In Trigger Functions**

| <p>Function</p><p>Description</p><p>Example Usage</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><code>suppress\_redundant\_updates\_trigger</code> ( ) → <code>trigger</code></p><p>Suppresses do-nothing update operations. See below for details.</p><p><code>CREATE TRIGGER ... suppress\_redundant\_updates\_trigger()</code></p>                                                                                                                                                                                                                                                                   |
| <p><code>tsvector\_update\_trigger</code> ( ) → <code>trigger</code></p><p>Automatically updates a <code>tsvector</code> column from associated plain-text document column(s). The text search configuration to use is specified by name as a trigger argument. See <a href="/pages/CJZE0XCbInD2PmIbuvg7#TEXTSEARCH-UPDATE-TRIGGERS">Section 12.4.3</a> for details.</p><p><code>CREATE TRIGGER ... tsvector\_update\_trigger(tsvcol, 'pg\_catalog.swedish', title, body)</code></p>                       |
| <p><code>tsvector\_update\_trigger\_column</code> ( ) → <code>trigger</code></p><p>Automatically updates a <code>tsvector</code> column from associated plain-text document column(s). The text search configuration to use is taken from a <code>regconfig</code> column of the table. See <a href="/pages/CJZE0XCbInD2PmIbuvg7#TEXTSEARCH-UPDATE-TRIGGERS">Section 12.4.3</a> for details.</p><p><code>CREATE TRIGGER ... tsvector\_update\_trigger\_column(tsvcol, tsconfigcol, title, body)</code></p> |

<br>

The `suppress_redundant_updates_trigger` function, when applied as a row-level `BEFORE UPDATE` trigger, will prevent any update that does not actually change the data in the row from taking place. This overrides the normal behavior which always performs a physical row update regardless of whether or not the data has changed. (This normal behavior makes updates run faster, since no checking is required, and is also useful in certain cases.)

Ideally, you should avoid running updates that don't actually change the data in the record. Redundant updates can cost considerable unnecessary time, especially if there are lots of indexes to alter, and space in dead rows that will eventually have to be vacuumed. However, detecting such situations in client code is not always easy, or even possible, and writing expressions to detect them can be error-prone. An alternative is to use `suppress_redundant_updates_trigger`, which will skip updates that don't change the data. You should use this with care, however. The trigger takes a small but non-trivial time for each record, so if most of the records affected by updates do actually change, use of this trigger will make updates run slower on average.

The `suppress_redundant_updates_trigger` function can be added to a table like this:

```

CREATE TRIGGER z_min_update
BEFORE UPDATE ON tablename
FOR EACH ROW EXECUTE FUNCTION suppress_redundant_updates_trigger();
```

In most cases, you need to fire this trigger last for each row, so that it does not override other triggers that might wish to alter the row. Bearing in mind that triggers fire in name order, you would therefore choose a trigger name that comes after the name of any other trigger you might have on the table. (Hence the “z” prefix in the example.)

***

原文：[PostgreSQL 18.6 Documentation](https://www.postgresql.org/docs/18/functions-trigger.html)（英文原文，待翻譯）


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.postgresql.tw/the-sql-language/functions/functions-trigger.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
