Home Explore Blog CI



postgresql

5th chunk of `doc/src/sgml/monitoring.sgml`
86d88b6b8cca6cc3e10530799805c5710c63e8ecac94da080000000100000fad
 information will (when in snapshot mode) cause a
   new snapshot to be built or (when in cache mode) accessed statistics to be
   cached.
  </para>

  <para>
   A transaction can also see its own statistics (not yet flushed out to the
   shared memory statistics) in the views
   <structname>pg_stat_xact_all_tables</structname>,
   <structname>pg_stat_xact_sys_tables</structname>,
   <structname>pg_stat_xact_user_tables</structname>, and
   <structname>pg_stat_xact_user_functions</structname>.  These numbers do not act as
   stated above; instead they update continuously throughout the transaction.
  </para>

  <para>
   Some of the information in the dynamic statistics views shown in <xref
   linkend="monitoring-stats-dynamic-views-table"/> is security restricted.
   Ordinary users can only see all the information about their own sessions
   (sessions belonging to a role that they are a member of).  In rows about
   other sessions, many columns will be null.  Note, however, that the
   existence of a session and its general properties such as its sessions user
   and database are visible to all users.  Superusers and roles with privileges of
   built-in role <link linkend="predefined-role-pg-monitor"><literal>pg_read_all_stats</literal></link>
   can see all the information about all sessions.
  </para>

  <table id="monitoring-stats-dynamic-views-table">
   <title>Dynamic Statistics Views</title>

   <tgroup cols="2">
    <thead>
     <row>
      <entry>View Name</entry>
      <entry>Description</entry>
     </row>
    </thead>

    <tbody>
     <row>
      <entry>
       <structname>pg_stat_activity</structname>
       <indexterm><primary>pg_stat_activity</primary></indexterm>
      </entry>
      <entry>
       One row per server process, showing information related to
       the current activity of that process, such as state and current query.
       See <link linkend="monitoring-pg-stat-activity-view">
       <structname>pg_stat_activity</structname></link> for details.
      </entry>
     </row>

     <row>
      <entry><structname>pg_stat_replication</structname><indexterm><primary>pg_stat_replication</primary></indexterm></entry>
      <entry>One row per WAL sender process, showing statistics about
       replication to that sender's connected standby server.
       See <link linkend="monitoring-pg-stat-replication-view">
       <structname>pg_stat_replication</structname></link> for details.
      </entry>
     </row>

     <row>
      <entry><structname>pg_stat_wal_receiver</structname><indexterm><primary>pg_stat_wal_receiver</primary></indexterm></entry>
      <entry>Only one row, showing statistics about the WAL receiver from
       that receiver's connected server.
       See <link linkend="monitoring-pg-stat-wal-receiver-view">
       <structname>pg_stat_wal_receiver</structname></link> for details.
      </entry>
     </row>

     <row>
      <entry><structname>pg_stat_recovery_prefetch</structname><indexterm><primary>pg_stat_recovery_prefetch</primary></indexterm></entry>
      <entry>Only one row, showing statistics about blocks prefetched during recovery.
       See <link linkend="monitoring-pg-stat-recovery-prefetch">
       <structname>pg_stat_recovery_prefetch</structname></link> for details.
      </entry>
     </row>

     <row>
      <entry><structname>pg_stat_subscription</structname><indexterm><primary>pg_stat_subscription</primary></indexterm></entry>
      <entry>At least one row per subscription, showing information about
       the subscription workers.
       See <link linkend="monitoring-pg-stat-subscription">
       <structname>pg_stat_subscription</structname></link> for details.
      </entry>
     </row>

     <row>
      <entry><structname>pg_stat_ssl</structname><indexterm><primary>pg_stat_ssl</primary></indexterm></entry>
      <entry>One row per connection (regular and replication), showing information about
       SSL used on this connection.
       See <link linkend="monitoring-pg-stat-ssl-view">

Title: Dynamic Statistics Views, Security, and pg_stat_activity
Summary
This section continues discussing how transactions can see their own statistics through specific views like pg_stat_xact_all_tables, which update continuously. It highlights security restrictions on dynamic statistics views, where ordinary users can only see full information about their own sessions. Superusers or roles with pg_read_all_stats privileges can view all session information. The section includes a table describing dynamic statistics views such as pg_stat_activity (information about server processes and current activity), pg_stat_replication (statistics about replication), pg_stat_wal_receiver (statistics about the WAL receiver), pg_stat_recovery_prefetch (statistics about recovery prefetching), pg_stat_subscription (information about subscription workers), and pg_stat_ssl (information about SSL connections).