<primary>pg_stat_get_backend_wait_event</primary>
</indexterm>
<function>pg_stat_get_backend_wait_event</function> ( <type>integer</type> )
<returnvalue>text</returnvalue>
</para>
<para>
Returns the wait event name if this backend is currently waiting,
otherwise NULL. See <xref linkend="wait-event-activity-table"/> through
<xref linkend="wait-event-timeout-table"/>.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm>
<primary>pg_stat_get_backend_wait_event_type</primary>
</indexterm>
<function>pg_stat_get_backend_wait_event_type</function> ( <type>integer</type> )
<returnvalue>text</returnvalue>
</para>
<para>
Returns the wait event type name if this backend is currently waiting,
otherwise NULL. See <xref linkend="wait-event-table"/> for details.
</para></entry>
</row>
<row>
<entry role="func_table_entry"><para role="func_signature">
<indexterm>
<primary>pg_stat_get_backend_xact_start</primary>
</indexterm>
<function>pg_stat_get_backend_xact_start</function> ( <type>integer</type> )
<returnvalue>timestamp with time zone</returnvalue>
</para>
<para>
Returns the time when the backend's current transaction was started.
</para></entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
</sect1>
<sect1 id="monitoring-locks">
<title>Viewing Locks</title>
<indexterm zone="monitoring-locks">
<primary>lock</primary>
<secondary>monitoring</secondary>
</indexterm>
<para>
Another useful tool for monitoring database activity is the
<structname>pg_locks</structname> system table. It allows the
database administrator to view information about the outstanding
locks in the lock manager. For example, this capability can be used
to:
<itemizedlist>
<listitem>
<para>
View all the locks currently outstanding, all the locks on
relations in a particular database, all the locks on a
particular relation, or all the locks held by a particular
<productname>PostgreSQL</productname> session.
</para>
</listitem>
<listitem>
<para>
Determine the relation in the current database with the most
ungranted locks (which might be a source of contention among
database clients).
</para>
</listitem>
<listitem>
<para>
Determine the effect of lock contention on overall database
performance, as well as the extent to which contention varies
with overall database traffic.
</para>
</listitem>
</itemizedlist>
Details of the <structname>pg_locks</structname> view appear in
<xref linkend="view-pg-locks"/>.
For more information on locking and managing concurrency with
<productname>PostgreSQL</productname>, refer to <xref linkend="mvcc"/>.
</para>
</sect1>
<sect1 id="progress-reporting">
<title>Progress Reporting</title>
<para>
<productname>PostgreSQL</productname> has the ability to report the progress of
certain commands during command execution. Currently, the only commands
which support progress reporting are <command>ANALYZE</command>,
<command>CLUSTER</command>,
<command>CREATE INDEX</command>, <command>VACUUM</command>,
<command>COPY</command>,
and <xref linkend="protocol-replication-base-backup"/> (i.e., replication
command that <xref linkend="app-pgbasebackup"/> issues to take
a base backup).
This may be expanded in the future.
</para>
<sect2 id="analyze-progress-reporting">
<title>ANALYZE Progress Reporting</title>
<indexterm>
<primary>pg_stat_progress_analyze</primary>
</indexterm>
<para>
Whenever <command>ANALYZE</command> is running, the
<structname>pg_stat_progress_analyze</structname> view will contain a
row for each