]> begriffs open source - ai-pg/blob - full-docs/src/sgml/html/runtime-config-locks.html
WIP: toc builder
[ai-pg] / full-docs / src / sgml / html / runtime-config-locks.html
1 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>19.12. Lock Management</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="runtime-config-client.html" title="19.11. Client Connection Defaults" /><link rel="next" href="runtime-config-compatible.html" title="19.13. Version and Platform Compatibility" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">19.12. Lock Management</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="runtime-config-client.html" title="19.11. Client Connection Defaults">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="runtime-config.html" title="Chapter 19. Server Configuration">Up</a></td><th width="60%" align="center">Chapter 19. Server Configuration</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="runtime-config-compatible.html" title="19.13. Version and Platform Compatibility">Next</a></td></tr></table><hr /></div><div class="sect1" id="RUNTIME-CONFIG-LOCKS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">19.12. Lock Management <a href="#RUNTIME-CONFIG-LOCKS" class="id_link">#</a></h2></div></div></div><div class="variablelist"><dl class="variablelist"><dt id="GUC-DEADLOCK-TIMEOUT"><span class="term"><code class="varname">deadlock_timeout</code> (<code class="type">integer</code>)
3       <a id="id-1.6.6.15.2.1.1.3" class="indexterm"></a>
4       <a id="id-1.6.6.15.2.1.1.4" class="indexterm"></a>
5       <a id="id-1.6.6.15.2.1.1.5" class="indexterm"></a>
6       </span> <a href="#GUC-DEADLOCK-TIMEOUT" class="id_link">#</a></dt><dd><p>
7         This is the amount of time to wait on a lock
8         before checking to see if there is a deadlock condition. The
9         check for deadlock is relatively expensive, so the server doesn't run
10         it every time it waits for a lock. We optimistically assume
11         that deadlocks are not common in production applications and
12         just wait on the lock for a while before checking for a
13         deadlock. Increasing this value reduces the amount of time
14         wasted in needless deadlock checks, but slows down reporting of
15         real deadlock errors.
16         If this value is specified without units, it is taken as milliseconds.
17         The default is one second (<code class="literal">1s</code>),
18         which is probably about the smallest value you would want in
19         practice. On a heavily loaded server you might want to raise it.
20         Ideally the setting should exceed your typical transaction time,
21         so as to improve the odds that a lock will be released before
22         the waiter decides to check for deadlock.
23         Only superusers and users with the appropriate <code class="literal">SET</code>
24         privilege can change this setting.
25        </p><p>
26         When <a class="xref" href="runtime-config-logging.html#GUC-LOG-LOCK-WAITS">log_lock_waits</a> is set,
27         this parameter also determines the amount of time to wait before
28         a log message is issued about the lock wait.  If you are trying
29         to investigate locking delays you might want to set a shorter than
30         normal <code class="varname">deadlock_timeout</code>.
31        </p></dd><dt id="GUC-MAX-LOCKS-PER-TRANSACTION"><span class="term"><code class="varname">max_locks_per_transaction</code> (<code class="type">integer</code>)
32       <a id="id-1.6.6.15.2.2.1.3" class="indexterm"></a>
33       </span> <a href="#GUC-MAX-LOCKS-PER-TRANSACTION" class="id_link">#</a></dt><dd><p>
34         The shared lock table has space for
35         <code class="varname">max_locks_per_transaction</code> objects
36         (e.g., tables) per server process or prepared transaction;
37         hence, no more than this many distinct objects can be locked at
38         any one time.  This parameter limits the average number of object
39         locks used by each transaction; individual transactions
40         can lock more objects as long as the locks of all transactions
41         fit in the lock table.  This is <span class="emphasis"><em>not</em></span> the number of
42         rows that can be locked; that value is unlimited.  The default,
43         64, has historically proven sufficient, but you might need to
44         raise this value if you have queries that touch many different
45         tables in a single transaction, e.g., query of a parent table with
46         many children.  This parameter can only be set at server start.
47        </p><p>
48         When running a standby server, you must set this parameter to have the
49         same or higher value as on the primary server. Otherwise, queries
50         will not be allowed in the standby server.
51        </p></dd><dt id="GUC-MAX-PRED-LOCKS-PER-TRANSACTION"><span class="term"><code class="varname">max_pred_locks_per_transaction</code> (<code class="type">integer</code>)
52       <a id="id-1.6.6.15.2.3.1.3" class="indexterm"></a>
53       </span> <a href="#GUC-MAX-PRED-LOCKS-PER-TRANSACTION" class="id_link">#</a></dt><dd><p>
54         The shared predicate lock table has space for
55         <code class="varname">max_pred_locks_per_transaction</code> objects
56         (e.g., tables) per server process or prepared transaction;
57         hence, no more than this many distinct objects can be locked at
58         any one time.  This parameter limits the average number of object
59         locks used by each transaction; individual transactions
60         can lock more objects as long as the locks of all transactions
61         fit in the lock table.  This is <span class="emphasis"><em>not</em></span> the number of
62         rows that can be locked; that value is unlimited.  The default,
63         64, has historically proven sufficient, but you might need to
64         raise this value if you have clients that touch many different
65         tables in a single serializable transaction. This parameter can
66         only be set at server start.
67        </p></dd><dt id="GUC-MAX-PRED-LOCKS-PER-RELATION"><span class="term"><code class="varname">max_pred_locks_per_relation</code> (<code class="type">integer</code>)
68       <a id="id-1.6.6.15.2.4.1.3" class="indexterm"></a>
69       </span> <a href="#GUC-MAX-PRED-LOCKS-PER-RELATION" class="id_link">#</a></dt><dd><p>
70         This controls how many pages or tuples of a single relation can be
71         predicate-locked before the lock is promoted to covering the whole
72         relation.  Values greater than or equal to zero mean an absolute
73         limit, while negative values
74         mean <a class="xref" href="runtime-config-locks.html#GUC-MAX-PRED-LOCKS-PER-TRANSACTION">max_pred_locks_per_transaction</a> divided by
75         the absolute value of this setting.  The default is -2, which keeps
76         the behavior from previous versions of <span class="productname">PostgreSQL</span>.
77         This parameter can only be set in the <code class="filename">postgresql.conf</code>
78         file or on the server command line.
79        </p></dd><dt id="GUC-MAX-PRED-LOCKS-PER-PAGE"><span class="term"><code class="varname">max_pred_locks_per_page</code> (<code class="type">integer</code>)
80       <a id="id-1.6.6.15.2.5.1.3" class="indexterm"></a>
81       </span> <a href="#GUC-MAX-PRED-LOCKS-PER-PAGE" class="id_link">#</a></dt><dd><p>
82         This controls how many rows on a single page can be predicate-locked
83         before the lock is promoted to covering the whole page.  The default
84         is 2.  This parameter can only be set in
85         the <code class="filename">postgresql.conf</code> file or on the server command line.
86        </p></dd></dl></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="runtime-config-client.html" title="19.11. Client Connection Defaults">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="runtime-config.html" title="Chapter 19. Server Configuration">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="runtime-config-compatible.html" title="19.13. Version and Platform Compatibility">Next</a></td></tr><tr><td width="40%" align="left" valign="top">19.11. Client Connection Defaults </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 18.0 Documentation">Home</a></td><td width="40%" align="right" valign="top"> 19.13. Version and Platform Compatibility</td></tr></table></div></body></html>