|
7100 | 7100 | in the same way as in <structname>pg_description</structname> or
|
7101 | 7101 | <structname>pg_depend</structname>). Also, the right to extend a
|
7102 | 7102 | relation is represented as a separate lockable object.
|
| 7103 | + Also, <quote>advisory</> locks can be taken on numbers that have |
| 7104 | + user-defined meanings. |
7103 | 7105 | </para>
|
7104 | 7106 |
|
7105 | 7107 | <table>
|
|
7202 | 7204 | <entry>any OID column</entry>
|
7203 | 7205 | <entry>
|
7204 | 7206 | OID of the lock target within its system catalog, or null if the
|
7205 |
| - target is not a general database object. |
7206 |
| - For advisory locks it is used to distinguish the two key |
7207 |
| - spaces (1 for an int8 key, 2 for two int4 keys). |
| 7207 | + target is not a general database object |
7208 | 7208 | </entry>
|
7209 | 7209 | </row>
|
7210 | 7210 | <row>
|
|
7233 | 7233 | <entry></entry>
|
7234 | 7234 | <entry>
|
7235 | 7235 | Process ID of the server process holding or awaiting this
|
7236 |
| - lock. Null if the lock is held by a prepared transaction. |
| 7236 | + lock, or null if the lock is held by a prepared transaction |
7237 | 7237 | </entry>
|
7238 | 7238 | </row>
|
7239 | 7239 | <row>
|
|
7253 | 7253 | <entry><structfield>fastpath</structfield></entry>
|
7254 | 7254 | <entry><type>boolean</type></entry>
|
7255 | 7255 | <entry></entry>
|
7256 |
| - <entry>True if lock was taken via fast path, false if taken via main lock table</entry> |
| 7256 | + <entry>True if lock was taken via fast path, false if taken via main |
| 7257 | + lock table</entry> |
7257 | 7258 | </row>
|
7258 | 7259 | </tbody>
|
7259 | 7260 | </tgroup>
|
|
7292 | 7293 |
|
7293 | 7294 | <para>
|
7294 | 7295 | Advisory locks can be acquired on keys consisting of either a single
|
7295 |
| - <type>bigint</type> value or two integer values. A <type>bigint</type> key is displayed with its |
| 7296 | + <type>bigint</type> value or two integer values. |
| 7297 | + A <type>bigint</type> key is displayed with its |
7296 | 7298 | high-order half in the <structfield>classid</> column, its low-order half
|
7297 | 7299 | in the <structfield>objid</> column, and <structfield>objsubid</> equal
|
7298 | 7300 | to 1. Integer keys are displayed with the first key in the
|
|
7302 | 7304 | so the <structfield>database</> column is meaningful for an advisory lock.
|
7303 | 7305 | </para>
|
7304 | 7306 |
|
7305 |
| - <para> |
7306 |
| - The <structname>pg_locks</structname> view displays data from both the |
7307 |
| - regular lock manager and the predicate lock manager, which are |
7308 |
| - separate systems. This data is not guaranteed to be entirely consistent. |
7309 |
| - Data on fast-path locks (with <structfield>fastpath</> = <literal>true</>) |
7310 |
| - is gathered from each backend one at a time, without freezing the state of |
7311 |
| - the entire lock manager, so it is possible for locks to be taken and |
7312 |
| - released as information is gathered. Note, however, that these locks are |
7313 |
| - known not to conflict with any other lock currently in place. After |
7314 |
| - all backends have been queried for fast-path locks, the remainder of the |
7315 |
| - lock manager is locked as a unit, and a consistent snapshot of all |
7316 |
| - remaining locks is dumped as an atomic action. Once the lock manager has |
7317 |
| - been unlocked, the predicate lock manager is similarly locked and all |
7318 |
| - predicate locks are dumped as an atomic action. Thus, with the exception |
7319 |
| - of fast-path locks, each lock manager will deliver a consistent set of |
7320 |
| - results, but as we do not lock both lock managers simultaneously, it is |
7321 |
| - possible for locks to be taken or released after we interrogate the regular |
7322 |
| - lock manager and before we interrogate the predicate lock manager. |
7323 |
| - </para> |
7324 |
| - |
7325 |
| - <para> |
7326 |
| - Locking the lock manger and/or predicate lock manager could have some |
7327 |
| - impact on database performance if this view is very frequently accessed. |
7328 |
| - The locks are held only for the minimum amount of time necessary to |
7329 |
| - obtain data from the lock manager, but this does not completely eliminate |
7330 |
| - the possibility of a performance impact. |
7331 |
| - </para> |
7332 |
| - |
7333 | 7307 | <para>
|
7334 | 7308 | <structname>pg_locks</structname> provides a global view of all locks
|
7335 | 7309 | in the database cluster, not only those relevant to the current database.
|
|
7354 | 7328 | but it continues to hold the locks it acquired while running.)
|
7355 | 7329 | </para>
|
7356 | 7330 |
|
| 7331 | + <para> |
| 7332 | + The <structname>pg_locks</structname> view displays data from both the |
| 7333 | + regular lock manager and the predicate lock manager, which are |
| 7334 | + separate systems; in addition, the regular lock manager subdivides its |
| 7335 | + locks into regular and <firstterm>fast-path</> locks. |
| 7336 | + This data is not guaranteed to be entirely consistent. |
| 7337 | + When the view is queried, |
| 7338 | + data on fast-path locks (with <structfield>fastpath</> = <literal>true</>) |
| 7339 | + is gathered from each backend one at a time, without freezing the state of |
| 7340 | + the entire lock manager, so it is possible for locks to be taken or |
| 7341 | + released while information is gathered. Note, however, that these locks are |
| 7342 | + known not to conflict with any other lock currently in place. After |
| 7343 | + all backends have been queried for fast-path locks, the remainder of the |
| 7344 | + regular lock manager is locked as a unit, and a consistent snapshot of all |
| 7345 | + remaining locks is collected as an atomic action. After unlocking the |
| 7346 | + regular lock manager, the predicate lock manager is similarly locked and all |
| 7347 | + predicate locks are collected as an atomic action. Thus, with the exception |
| 7348 | + of fast-path locks, each lock manager will deliver a consistent set of |
| 7349 | + results, but as we do not lock both lock managers simultaneously, it is |
| 7350 | + possible for locks to be taken or released after we interrogate the regular |
| 7351 | + lock manager and before we interrogate the predicate lock manager. |
| 7352 | + </para> |
| 7353 | + |
| 7354 | + <para> |
| 7355 | + Locking the regular and/or predicate lock manager could have some |
| 7356 | + impact on database performance if this view is very frequently accessed. |
| 7357 | + The locks are held only for the minimum amount of time necessary to |
| 7358 | + obtain data from the lock managers, but this does not completely eliminate |
| 7359 | + the possibility of a performance impact. |
| 7360 | + </para> |
| 7361 | + |
7357 | 7362 | </sect1>
|
7358 | 7363 |
|
7359 | 7364 | <sect1 id="view-pg-prepared-statements">
|
|
0 commit comments