gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

51 lines
6.8KB

  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>F.28. pgrowlocks</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 V1.79.1" /><link rel="prev" href="pgprewarm.html" title="F.27. pg_prewarm" /><link rel="next" href="pgstatstatements.html" title="F.29. pg_stat_statements" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">F.28. pgrowlocks</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="pgprewarm.html" title="F.27. pg_prewarm">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="contrib.html" title="Appendix F. Additional Supplied Modules">Up</a></td><th width="60%" align="center">Appendix F. Additional Supplied Modules</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 12.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="pgstatstatements.html" title="F.29. pg_stat_statements">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="PGROWLOCKS"><div class="titlepage"><div><div><h2 class="title" style="clear: both">F.28. pgrowlocks</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="pgrowlocks.html#id-1.11.7.37.5">F.28.1. Overview</a></span></dt><dt><span class="sect2"><a href="pgrowlocks.html#id-1.11.7.37.6">F.28.2. Sample Output</a></span></dt><dt><span class="sect2"><a href="pgrowlocks.html#id-1.11.7.37.7">F.28.3. Author</a></span></dt></dl></div><a id="id-1.11.7.37.2" class="indexterm"></a><p>
  3. The <code class="filename">pgrowlocks</code> module provides a function to show row
  4. locking information for a specified table.
  5. </p><p>
  6. By default use is restricted to superusers, members of the
  7. <code class="literal">pg_stat_scan_tables</code> role, and users with
  8. <code class="literal">SELECT</code> permissions on the table.
  9. </p><div class="sect2" id="id-1.11.7.37.5"><div class="titlepage"><div><div><h3 class="title">F.28.1. Overview</h3></div></div></div><a id="id-1.11.7.37.5.2" class="indexterm"></a><pre class="synopsis">
  10. pgrowlocks(text) returns setof record
  11. </pre><p>
  12. The parameter is the name of a table. The result is a set of records,
  13. with one row for each locked row within the table. The output columns
  14. are shown in <a class="xref" href="pgrowlocks.html#PGROWLOCKS-COLUMNS" title="Table F.20. pgrowlocks Output Columns">Table F.20</a>.
  15. </p><div class="table" id="PGROWLOCKS-COLUMNS"><p class="title"><strong>Table F.20. <code class="function">pgrowlocks</code> Output Columns</strong></p><div class="table-contents"><table class="table" summary="pgrowlocks Output Columns" border="1"><colgroup><col /><col /><col /></colgroup><thead><tr><th>Name</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><code class="structfield">locked_row</code></td><td><code class="type">tid</code></td><td>Tuple ID (TID) of locked row</td></tr><tr><td><code class="structfield">locker</code></td><td><code class="type">xid</code></td><td>Transaction ID of locker, or multixact ID if multitransaction</td></tr><tr><td><code class="structfield">multi</code></td><td><code class="type">boolean</code></td><td>True if locker is a multitransaction</td></tr><tr><td><code class="structfield">xids</code></td><td><code class="type">xid[]</code></td><td>Transaction IDs of lockers (more than one if multitransaction)</td></tr><tr><td><code class="structfield">modes</code></td><td><code class="type">text[]</code></td><td>Lock mode of lockers (more than one if multitransaction),
  16. an array of <code class="literal">Key Share</code>, <code class="literal">Share</code>,
  17. <code class="literal">For No Key Update</code>, <code class="literal">No Key Update</code>,
  18. <code class="literal">For Update</code>, <code class="literal">Update</code>.</td></tr><tr><td><code class="structfield">pids</code></td><td><code class="type">integer[]</code></td><td>Process IDs of locking backends (more than one if multitransaction)</td></tr></tbody></table></div></div><br class="table-break" /><p>
  19. <code class="function">pgrowlocks</code> takes <code class="literal">AccessShareLock</code> for the
  20. target table and reads each row one by one to collect the row locking
  21. information. This is not very speedy for a large table. Note that:
  22. </p><div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem"><p>
  23. If the table as a whole is exclusive-locked by someone else,
  24. <code class="function">pgrowlocks</code> will be blocked.
  25. </p></li><li class="listitem"><p>
  26. <code class="function">pgrowlocks</code> is not guaranteed to produce a
  27. self-consistent snapshot. It is possible that a new row lock is taken,
  28. or an old lock is freed, during its execution.
  29. </p></li></ol></div><p>
  30. <code class="function">pgrowlocks</code> does not show the contents of locked
  31. rows. If you want to take a look at the row contents at the same time, you
  32. could do something like this:
  33. </p><pre class="programlisting">
  34. SELECT * FROM accounts AS a, pgrowlocks('accounts') AS p
  35. WHERE p.locked_row = a.ctid;
  36. </pre><p>
  37. Be aware however that such a query will be very inefficient.
  38. </p></div><div class="sect2" id="id-1.11.7.37.6"><div class="titlepage"><div><div><h3 class="title">F.28.2. Sample Output</h3></div></div></div><pre class="screen">
  39. =# SELECT * FROM pgrowlocks('t1');
  40. locked_row | locker | multi | xids | modes | pids
  41. ------------+--------+-------+-------+----------------+--------
  42. (0,1) | 609 | f | {609} | {"For Share"} | {3161}
  43. (0,2) | 609 | f | {609} | {"For Share"} | {3161}
  44. (0,3) | 607 | f | {607} | {"For Update"} | {3107}
  45. (0,4) | 607 | f | {607} | {"For Update"} | {3107}
  46. (4 rows)
  47. </pre></div><div class="sect2" id="id-1.11.7.37.7"><div class="titlepage"><div><div><h3 class="title">F.28.3. Author</h3></div></div></div><p>
  48. Tatsuo Ishii
  49. </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="pgprewarm.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="contrib.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="pgstatstatements.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">F.27. pg_prewarm </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> F.29. pg_stat_statements</td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1