Sophie

Sophie

distrib > Mandriva > 2006.0 > x86_64 > by-pkgid > b8f4049de69feba5041d49ed4382e582 > files > 613

postgresql-docs-8.0.11-0.1.20060mdk.x86_64.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML
><HEAD
><TITLE
>pg_locks</TITLE
><META
NAME="GENERATOR"
CONTENT="Modular DocBook HTML Stylesheet Version 1.79"><LINK
REV="MADE"
HREF="mailto:pgsql-docs@postgresql.org"><LINK
REL="HOME"
TITLE="PostgreSQL 8.0.11 Documentation"
HREF="index.html"><LINK
REL="UP"
TITLE="System Catalogs"
HREF="catalogs.html"><LINK
REL="PREVIOUS"
TITLE="pg_indexes"
HREF="view-pg-indexes.html"><LINK
REL="NEXT"
TITLE="pg_rules"
HREF="view-pg-rules.html"><LINK
REL="STYLESHEET"
TYPE="text/css"
HREF="stylesheet.css"><META
HTTP-EQUIV="Content-Type"
CONTENT="text/html; charset=ISO-8859-1"><META
NAME="creation"
CONTENT="2007-02-02T03:57:22"></HEAD
><BODY
CLASS="SECT1"
><DIV
CLASS="NAVHEADER"
><TABLE
SUMMARY="Header navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TH
COLSPAN="5"
ALIGN="center"
VALIGN="bottom"
>PostgreSQL 8.0.11 Documentation</TH
></TR
><TR
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="view-pg-indexes.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="10%"
ALIGN="left"
VALIGN="top"
><A
HREF="catalogs.html"
>Fast Backward</A
></TD
><TD
WIDTH="60%"
ALIGN="center"
VALIGN="bottom"
>Chapter 41. System Catalogs</TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="catalogs.html"
>Fast Forward</A
></TD
><TD
WIDTH="10%"
ALIGN="right"
VALIGN="top"
><A
HREF="view-pg-rules.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><DIV
CLASS="SECT1"
><H1
CLASS="SECT1"
><A
NAME="VIEW-PG-LOCKS"
>41.33. <TT
CLASS="STRUCTNAME"
>pg_locks</TT
></A
></H1
><A
NAME="AEN55222"
></A
><P
>   The view <TT
CLASS="STRUCTNAME"
>pg_locks</TT
> provides access to
   information about the locks held by open transactions within the
   database server.  See <A
HREF="mvcc.html"
>Chapter 12</A
> for more discussion
   of locking.
  </P
><P
>   <TT
CLASS="STRUCTNAME"
>pg_locks</TT
> contains one row per active lockable
   object, requested lock mode, and relevant transaction.  Thus, the same
   lockable object may
   appear many times, if multiple transactions are holding or waiting
   for locks on it.  However, an object that currently has no locks on it
   will not appear at all.  A lockable object is either a relation (e.g., a
   table) or a transaction ID.
  </P
><P
>   Note that this view includes only table-level
   locks, not row-level ones.  If a transaction is waiting for a
   row-level lock, it will appear in the view as waiting for the
   transaction ID of the current holder of that row lock.
  </P
><DIV
CLASS="TABLE"
><A
NAME="AEN55230"
></A
><P
><B
>Table 41-33. <TT
CLASS="STRUCTNAME"
>pg_locks</TT
> Columns</B
></P
><TABLE
BORDER="1"
CLASS="CALSTABLE"
><COL><COL><COL><COL><THEAD
><TR
><TH
>Name</TH
><TH
>Type</TH
><TH
>References</TH
><TH
>Description</TH
></TR
></THEAD
><TBODY
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>relation</TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
><TT
CLASS="LITERAL"
><A
HREF="catalog-pg-class.html"
><TT
CLASS="STRUCTNAME"
>pg_class</TT
></A
>.oid</TT
></TD
><TD
>       OID of the locked relation, or NULL if the lockable object
       is a transaction ID
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>database</TT
></TD
><TD
><TT
CLASS="TYPE"
>oid</TT
></TD
><TD
><TT
CLASS="LITERAL"
><A
HREF="catalog-pg-database.html"
><TT
CLASS="STRUCTNAME"
>pg_database</TT
></A
>.oid</TT
></TD
><TD
>       OID of the database in which the locked relation exists, or
       zero if the locked relation is a globally-shared table, or
       NULL if the lockable object is a transaction ID
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>transaction</TT
></TD
><TD
><TT
CLASS="TYPE"
>xid</TT
></TD
><TD
>&nbsp;</TD
><TD
>       ID of a transaction, or NULL if the lockable object is a relation
      </TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>pid</TT
></TD
><TD
><TT
CLASS="TYPE"
>integer</TT
></TD
><TD
>&nbsp;</TD
><TD
>process ID of a server process holding or awaiting this
      lock</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>mode</TT
></TD
><TD
><TT
CLASS="TYPE"
>text</TT
></TD
><TD
>&nbsp;</TD
><TD
>name of the lock mode held or desired by this process (see <A
HREF="explicit-locking.html#LOCKING-TABLES"
>Section 12.3.1</A
>)</TD
></TR
><TR
><TD
><TT
CLASS="STRUCTFIELD"
>granted</TT
></TD
><TD
><TT
CLASS="TYPE"
>boolean</TT
></TD
><TD
>&nbsp;</TD
><TD
>true if lock is held, false if lock is awaited</TD
></TR
></TBODY
></TABLE
></DIV
><P
>   <TT
CLASS="STRUCTFIELD"
>granted</TT
> is true in a row representing a lock
   held by the indicated session.  False indicates that this session is
   currently waiting to acquire this lock, which implies that some other
   session is holding a conflicting lock mode on the same lockable object.
   The waiting session will sleep until the other lock is released (or a
   deadlock situation is detected). A single session can be waiting to acquire
   at most one lock at a time.
  </P
><P
>   Every transaction holds an exclusive lock on its transaction ID for its
   entire duration. If one transaction finds it necessary to wait specifically
   for another transaction, it does so by attempting to acquire share lock on
   the other transaction ID. That will succeed only when the other transaction
   terminates and releases its locks. 
  </P
><P
>   When the <TT
CLASS="STRUCTNAME"
>pg_locks</TT
> view is accessed, the
   internal lock manager data structures are momentarily locked, and
   a copy is made for the view to display.  This ensures that the
   view produces a consistent set of results, while not blocking
   normal lock manager operations longer than necessary.  Nonetheless
   there could be some impact on database performance if this view is
   read often.
  </P
><P
>   <TT
CLASS="STRUCTNAME"
>pg_locks</TT
> provides a global view of all locks
   in the database cluster, not only those relevant to the current database.
   Although its <TT
CLASS="STRUCTFIELD"
>relation</TT
> column can be joined
   against <TT
CLASS="STRUCTNAME"
>pg_class</TT
>.<TT
CLASS="STRUCTFIELD"
>oid</TT
> to identify locked
   relations, this will only work correctly for relations in the current
   database (those for which the <TT
CLASS="STRUCTFIELD"
>database</TT
> column
   is either the current database's OID or zero).
  </P
><P
>   If you have enabled the statistics collector, the
   <TT
CLASS="STRUCTFIELD"
>pid</TT
> column can be joined to the
   <TT
CLASS="STRUCTFIELD"
>procpid</TT
> column of the
   <TT
CLASS="STRUCTNAME"
>pg_stat_activity</TT
> view to get more
   information on the session holding or waiting to hold the lock.
  </P
></DIV
><DIV
CLASS="NAVFOOTER"
><HR
ALIGN="LEFT"
WIDTH="100%"><TABLE
SUMMARY="Footer navigation table"
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><A
HREF="view-pg-indexes.html"
ACCESSKEY="P"
>Prev</A
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="index.html"
ACCESSKEY="H"
>Home</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><A
HREF="view-pg-rules.html"
ACCESSKEY="N"
>Next</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
><TT
CLASS="STRUCTNAME"
>pg_indexes</TT
></TD
><TD
WIDTH="34%"
ALIGN="center"
VALIGN="top"
><A
HREF="catalogs.html"
ACCESSKEY="U"
>Up</A
></TD
><TD
WIDTH="33%"
ALIGN="right"
VALIGN="top"
><TT
CLASS="STRUCTNAME"
>pg_rules</TT
></TD
></TR
></TABLE
></DIV
></BODY
></HTML
>