1
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5
>Trigger Functions</TITLE
8
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
10
HREF="mailto:pgsql-docs@postgresql.org"><LINK
12
TITLE="PostgreSQL 9.1beta1 Documentation"
13
HREF="index.html"><LINK
15
TITLE="Functions and Operators"
16
HREF="functions.html"><LINK
18
TITLE="System Administration Functions"
19
HREF="functions-admin.html"><LINK
21
TITLE="Type Conversion"
22
HREF="typeconv.html"><LINK
25
HREF="stylesheet.css"><META
26
HTTP-EQUIV="Content-Type"
27
CONTENT="text/html; charset=ISO-8859-1"><META
29
CONTENT="2011-04-27T21:20:33"></HEAD
35
SUMMARY="Header navigation table"
47
>PostgreSQL 9.1beta1 Documentation</A
56
TITLE="System Administration Functions"
57
HREF="functions-admin.html"
66
TITLE="Functions and Operators"
74
>Chapter 9. Functions and Operators</TD
80
TITLE="Functions and Operators"
89
TITLE="Type Conversion"
104
NAME="FUNCTIONS-TRIGGER"
105
>9.25. Trigger Functions</A
111
> provides one built in trigger
114
>suppress_redundant_updates_trigger</CODE
116
which will prevent any update
117
that does not actually change the data in the row from taking place, in
118
contrast to the normal behavior which always performs the update
119
regardless of whether or not the data has changed. (This normal behavior
120
makes updates run faster, since no checking is required, and is also
121
useful in certain cases.)
124
> Ideally, you should normally avoid running updates that don't actually
125
change the data in the record. Redundant updates can cost considerable
126
unnecessary time, especially if there are lots of indexes to alter,
127
and space in dead rows that will eventually have to be vacuumed.
128
However, detecting such situations in client code is not
129
always easy, or even possible, and writing expressions to detect
130
them can be error-prone. An alternative is to use
133
>suppress_redundant_updates_trigger</CODE
135
updates that don't change the data. You should use this with care,
136
however. The trigger takes a small but non-trivial time for each record,
137
so if most of the records affected by an update are actually changed,
138
use of this trigger will actually make the update run slower.
143
>suppress_redundant_updates_trigger</CODE
145
added to a table like this:
147
CLASS="PROGRAMLISTING"
148
>CREATE TRIGGER z_min_update
149
BEFORE UPDATE ON tablename
150
FOR EACH ROW EXECUTE PROCEDURE suppress_redundant_updates_trigger();</PRE
152
In most cases, you would want to fire this trigger last for each row.
153
Bearing in mind that triggers fire in name order, you would then
154
choose a trigger name that comes after the name of any other trigger
155
you might have on the table.
158
> For more information about creating triggers, see
160
HREF="sql-createtrigger.html"
170
SUMMARY="Footer navigation table"
181
HREF="functions-admin.html"
209
>System Administration Functions</TD
215
HREF="functions.html"
b'\\ No newline at end of file'