@@ -242,20 +242,20 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
242
242
243
243
<tbody>
244
244
<row>
245
- <entry><structname>pg_stat_activity</><indexterm><primary>pg_stat_activity</primary></indexterm></entry>
246
- <entry>One row per server process, showing database OID, database
247
- name, process <acronym>ID</>, user OID, user name, application name,
248
- client's address, host name (if available), and port number, times at
249
- which the server process, current transaction, and current query began
250
- execution, process's waiting status, and text of the current query.
251
- The columns that report data on the current query are available unless
252
- the parameter <varname>track_activities</varname> has been turned off.
253
- Furthermore, these columns are only visible if the user examining
254
- the view is a superuser or the same as the user owning the process
255
- being reported on. The client's host name will be available only if
256
- <xref linkend="guc-log-hostname"> is set or if the user's host name
257
- needed to be looked up during <filename>pg_hba.conf</filename>
258
- processing.
245
+ <entry>
246
+ <structname>pg_stat_activity</structname>
247
+ <indexterm><primary>pg_stat_activity</primary></indexterm>
248
+ </entry>
249
+ <entry>
250
+ <para>One row per server process, showing information related to
251
+ each connection to the server. Unless the
252
+ <xref linkend="guc-track-activities"> parameter has been turned
253
+ off, it is possible to monitor state and query information of
254
+ all running processes.
255
+ </para>
256
+ <para>
257
+ See <xref linkend="pg-stat-activity-view"> for more details.
258
+ </para>
259
259
</entry>
260
260
</row>
261
261
@@ -529,6 +529,210 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
529
529
into the kernel's handling of I/O.
530
530
</para>
531
531
532
+ <table id="pg-stat-activity-view" xreflabel="pg_stat_activity">
533
+ <title>pg_stat_activity view</title>
534
+
535
+ <tgroup cols="3">
536
+ <thead>
537
+ <row>
538
+ <entry>Column</entry>
539
+ <entry>Type</entry>
540
+ <entry>Description</entry>
541
+ </row>
542
+ </thead>
543
+
544
+ <tbody>
545
+ <row>
546
+ <entry>datid</entry>
547
+ <entry><type>oid</></entry>
548
+ <entry>The oid of the database the backend is connected to.</entry>
549
+ </row>
550
+ <row>
551
+ <entry>datname</entry>
552
+ <entry><type>name</></entry>
553
+ <entry>The name of the database the backend is connected to.</entry>
554
+ </row>
555
+ <row>
556
+ <entry>pid</entry>
557
+ <entry><type>integer</></entry>
558
+ <entry>The process ID of the backend.</entry>
559
+ </row>
560
+ <row>
561
+ <entry>usesysid</entry>
562
+ <entry><type>oid</></entry>
563
+ <entry>The id of the user logged into the backend.</entry>
564
+ </row>
565
+ <row>
566
+ <entry>usename</entry>
567
+ <entry><type>name</></entry>
568
+ <entry>The name of the user logged into the backend.</entry>
569
+ </row>
570
+ <row>
571
+ <entry>application_name</entry>
572
+ <entry><type>text</></entry>
573
+ <entry>The name of the application that has initiated the connection
574
+ to the backend.</entry>
575
+ </row>
576
+ <row>
577
+ <entry>client_addr</entry>
578
+ <entry><type>inet</></entry>
579
+ <entry>The remote IP of the client connected to the backend.
580
+ If this field is not set, it indicates that the client is either:
581
+ <itemizedlist spacing="compact" mark="bullet">
582
+ <listitem>
583
+ <para>
584
+ Connected via unix sockets on the server machine
585
+ </para>
586
+ </listitem>
587
+ <listitem>
588
+ <para>An internal process such as autovacuum</para>
589
+ </listitem>
590
+ </itemizedlist>
591
+ </entry>
592
+ </row>
593
+ <row>
594
+ <entry>client_hostname</entry>
595
+ <entry><type>text</></entry>
596
+ <entry>
597
+ If available, the hostname of the client as reported by a
598
+ reverse lookup of <structfield>client_addr</>. This field will
599
+ only be set when <xref linkend="guc-log-hostname"> is enabled.
600
+ </entry>
601
+ </row>
602
+ <row>
603
+ <entry>client_port</entry>
604
+ <entry><type>integer</></entry>
605
+ <entry>
606
+ The remote TCP port that the client is using for communication
607
+ to the backend, or <symbol>NULL</> if a unix socket is used.
608
+ </entry>
609
+ </row>
610
+ <row>
611
+ <entry>backend_start</entry>
612
+ <entry><type>timestamp with time zone</></entry>
613
+ <entry>
614
+ The time when this process was started, i.e. when the
615
+ client connected to the server.
616
+ </entry>
617
+ </row>
618
+ <row>
619
+ <entry>xact_start</entry>
620
+ <entry><type>timestamp with time zone</></entry>
621
+ <entry>
622
+ The time when the current transaction was started. If the client is
623
+ using autocommit for transactions, this value is equal to the
624
+ query_start column.
625
+ </entry>
626
+ </row>
627
+ <row>
628
+ <entry>query_start</entry>
629
+ <entry><type>timestamp with time zone</></entry>
630
+ <entry>
631
+ The time when the currently active query started, or if
632
+ <structfield>state</> is <literal>idle</>, when the last query
633
+ was started.
634
+ </entry>
635
+ </row>
636
+ <row>
637
+ <entry>state_change</entry>
638
+ <entry><type>timestamp with time zone</></entry>
639
+ <entry>The time when the <structfield>state</> was last changed.</entry>
640
+ </row>
641
+ <row>
642
+ <entry>waiting</entry>
643
+ <entry><type>boolean</></entry>
644
+ <entry>
645
+ Boolean indicating if a backend is currently waiting on a lock.
646
+ </entry>
647
+ </row>
648
+ <row>
649
+ <entry>state</entry>
650
+ <entry><type>text</></entry>
651
+ <entry>
652
+ The <structfield>state</> of the currently running query.
653
+ Can be one of:
654
+ <variablelist>
655
+ <varlistentry>
656
+ <term>active</term>
657
+ <listitem>
658
+ <para>
659
+ The backend is executing a query.
660
+ </para>
661
+ </listitem>
662
+ </varlistentry>
663
+ <varlistentry>
664
+ <term>idle</term>
665
+ <listitem>
666
+ <para>
667
+ There is no query executing in the backend.
668
+ </para>
669
+ </listitem>
670
+ </varlistentry>
671
+ <varlistentry>
672
+ <term>idle in transaction</term>
673
+ <listitem>
674
+ <para>
675
+ The backend is in a transaction, but is currently not currently
676
+ executing a query.
677
+ </para>
678
+ </listitem>
679
+ </varlistentry>
680
+ <varlistentry>
681
+ <term>idle in transaction (aborted)</term>
682
+ <listitem>
683
+ <para>
684
+ This state is similar to <literal>idle in transaction</>,
685
+ except one of the statements in the transaction caused an error.
686
+ </para>
687
+ </listitem>
688
+ </varlistentry>
689
+ <varlistentry>
690
+ <term>fastpath function call</term>
691
+ <listitem>
692
+ <para>
693
+ The backend is executing a fast-path function.
694
+ </para>
695
+ </listitem>
696
+ </varlistentry>
697
+ <varlistentry>
698
+ <term>disabled</term>
699
+ <listitem>
700
+ <para>
701
+ This state indicates that <xref linkend="guc-track-activities">
702
+ is disabled.
703
+ </para>
704
+ </listitem>
705
+ </varlistentry>
706
+ </variablelist>
707
+ <note>
708
+ <para>
709
+ The <structfield>waiting</> and <structfield>state</> columns are
710
+ independent. If a query is in the <literal>active</> state,
711
+ it may or may not be <literal>waiting</>. If a query is
712
+ <literal>active</> and <structfield>waiting</> is true, it means
713
+ that the query is being executed, but is being blocked by a lock
714
+ somewhere in the system.
715
+ </para>
716
+ </note>
717
+ </entry>
718
+ </row>
719
+ <row>
720
+ <entry>query</entry>
721
+ <entry><type>text</></entry>
722
+ <entry>
723
+ The most recent query that the backend has executed. If
724
+ <structfield>state</> is <literal>active</> this means the currently
725
+ executing query. In all other states, it means the last query that was
726
+ executed.
727
+ </entry>
728
+ </row>
729
+ </tbody>
730
+ </tgroup>
731
+ </table>
732
+
733
+ <sect3 id="monitoring-stats-functions">
734
+ <title>Statistics Access Functions</title>
735
+
532
736
<para>
533
737
Other ways of looking at the statistics can be set up by writing
534
738
queries that use the same underlying statistics access functions as
@@ -1264,6 +1468,7 @@ SELECT pg_stat_get_backend_pid(s.backendid) AS procpid,
1264
1468
</programlisting>
1265
1469
</para>
1266
1470
1471
+ </sect3>
1267
1472
</sect2>
1268
1473
</sect1>
1269
1474
0 commit comments