1
- <!-- $PostgreSQL: pgsql/doc/src/sgml/monitoring.sgml,v 1.81 2010/07/29 19:34:40 petere Exp $ -->
1
+ <!-- $PostgreSQL: pgsql/doc/src/sgml/monitoring.sgml,v 1.82 2010/08/08 16:27:03 tgl Exp $ -->
2
2
3
3
<chapter id="monitoring">
4
4
<title>Monitoring Database Activity</title>
@@ -124,8 +124,8 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
124
124
125
125
<para>
126
126
<productname>PostgreSQL</productname> also supports reporting of the exact
127
- command currently being executed by other server processes. This is an
128
- facility independent of the collector process.
127
+ command currently being executed by other server processes. This
128
+ facility is independent of the collector process.
129
129
</para>
130
130
131
131
<sect2 id="monitoring-stats-setup">
@@ -165,8 +165,8 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
165
165
</para>
166
166
167
167
<para>
168
- The statistics collector communicates with the backends needing
169
- information (including autovacuum) through temporary files.
168
+ The statistics collector transmits the collected
169
+ information to backends (including autovacuum) through temporary files.
170
170
These files are stored in the <filename>pg_stat_tmp</filename> subdirectory.
171
171
When the postmaster shuts down, a permanent copy of the statistics
172
172
data is stored in the <filename>global</filename> subdirectory. For increased
@@ -219,6 +219,16 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
219
219
statistical information will cause a new snapshot to be fetched.
220
220
</para>
221
221
222
+ <para>
223
+ A transaction can also see its own statistics (as yet untransmitted to the
224
+ collector) in the views <structname>pg_stat_xact_all_tables</>,
225
+ <structname>pg_stat_xact_sys_tables</>,
226
+ <structname>pg_stat_xact_user_tables</>, and
227
+ <structname>pg_stat_xact_user_functions</>, or via these views' underlying
228
+ functions. These numbers do not act as stated above; instead they update
229
+ continuously throughout the transaction.
230
+ </para>
231
+
222
232
<table id="monitoring-stats-views-table">
223
233
<title>Standard Statistics Views</title>
224
234
@@ -299,6 +309,27 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
299
309
tables are shown.</entry>
300
310
</row>
301
311
312
+ <row>
313
+ <entry><structname>pg_stat_xact_all_tables</></entry>
314
+ <entry>Similar to <structname>pg_stat_all_tables</>, but counts actions
315
+ taken so far within the current transaction (which are <emphasis>not</>
316
+ yet included in <structname>pg_stat_all_tables</> and related views).
317
+ The columns for numbers of live and dead rows and last-vacuum and
318
+ last-analyze times are not present in this view.</entry>
319
+ </row>
320
+
321
+ <row>
322
+ <entry><structname>pg_stat_xact_sys_tables</></entry>
323
+ <entry>Same as <structname>pg_stat_xact_all_tables</>, except that only
324
+ system tables are shown.</entry>
325
+ </row>
326
+
327
+ <row>
328
+ <entry><structname>pg_stat_xact_user_tables</></entry>
329
+ <entry>Same as <structname>pg_stat_xact_all_tables</>, except that only
330
+ user tables are shown.</entry>
331
+ </row>
332
+
302
333
<row>
303
334
<entry><structname>pg_stat_all_indexes</></entry>
304
335
<entry>For each index in the current database,
@@ -395,6 +426,13 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
395
426
</entry>
396
427
</row>
397
428
429
+ <row>
430
+ <entry><structname>pg_stat_xact_user_functions</></entry>
431
+ <entry>Similar to <structname>pg_stat_user_functions</>, but counts only
432
+ calls during the current transaction (which are <emphasis>not</>
433
+ yet included in <structname>pg_stat_user_functions</>).</entry>
434
+ </row>
435
+
398
436
</tbody>
399
437
</tgroup>
400
438
</table>
@@ -405,7 +443,7 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
405
443
</para>
406
444
407
445
<para>
408
- Beginning in <productname>PostgreSQL</productname> 8.1, indexes can be
446
+ Indexes can be
409
447
used either directly or via <quote>bitmap scans</>. In a bitmap scan
410
448
the output of several indexes can be combined via AND or OR rules;
411
449
so it is difficult to associate individual heap row fetches
@@ -680,6 +718,82 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
680
718
</entry>
681
719
</row>
682
720
721
+ <row>
722
+ <entry><literal><function>pg_stat_get_xact_numscans</function>(<type>oid</type>)</literal></entry>
723
+ <entry><type>bigint</type></entry>
724
+ <entry>
725
+ Number of sequential scans done when argument is a table,
726
+ or number of index scans done when argument is an index, in the current transaction
727
+ </entry>
728
+ </row>
729
+
730
+ <row>
731
+ <entry><literal><function>pg_stat_get_xact_tuples_returned</function>(<type>oid</type>)</literal></entry>
732
+ <entry><type>bigint</type></entry>
733
+ <entry>
734
+ Number of rows read by sequential scans when argument is a table,
735
+ or number of index entries returned when argument is an index, in the current transaction
736
+ </entry>
737
+ </row>
738
+
739
+ <row>
740
+ <entry><literal><function>pg_stat_get_xact_tuples_fetched</function>(<type>oid</type>)</literal></entry>
741
+ <entry><type>bigint</type></entry>
742
+ <entry>
743
+ Number of table rows fetched by bitmap scans when argument is a table,
744
+ or table rows fetched by simple index scans using the index
745
+ when argument is an index, in the current transaction
746
+ </entry>
747
+ </row>
748
+
749
+ <row>
750
+ <entry><literal><function>pg_stat_get_xact_tuples_inserted</function>(<type>oid</type>)</literal></entry>
751
+ <entry><type>bigint</type></entry>
752
+ <entry>
753
+ Number of rows inserted into table, in the current transaction
754
+ </entry>
755
+ </row>
756
+
757
+ <row>
758
+ <entry><literal><function>pg_stat_get_xact_tuples_updated</function>(<type>oid</type>)</literal></entry>
759
+ <entry><type>bigint</type></entry>
760
+ <entry>
761
+ Number of rows updated in table (includes HOT updates), in the current transaction
762
+ </entry>
763
+ </row>
764
+
765
+ <row>
766
+ <entry><literal><function>pg_stat_get_xact_tuples_deleted</function>(<type>oid</type>)</literal></entry>
767
+ <entry><type>bigint</type></entry>
768
+ <entry>
769
+ Number of rows deleted from table, in the current transaction
770
+ </entry>
771
+ </row>
772
+
773
+ <row>
774
+ <entry><literal><function>pg_stat_get_xact_tuples_hot_updated</function>(<type>oid</type>)</literal></entry>
775
+ <entry><type>bigint</type></entry>
776
+ <entry>
777
+ Number of rows HOT-updated in table, in the current transaction
778
+ </entry>
779
+ </row>
780
+
781
+ <row>
782
+ <entry><literal><function>pg_stat_get_xact_blocks_fetched</function>(<type>oid</type>)</literal></entry>
783
+ <entry><type>bigint</type></entry>
784
+ <entry>
785
+ Number of disk block fetch requests for table or index, in the current transaction
786
+ </entry>
787
+ </row>
788
+
789
+ <row>
790
+ <entry><literal><function>pg_stat_get_xact_blocks_hit</function>(<type>oid</type>)</literal></entry>
791
+ <entry><type>bigint</type></entry>
792
+ <entry>
793
+ Number of disk block requests found in cache for table or index, in the current transaction
794
+ </entry>
795
+ </row>
796
+
683
797
<row>
684
798
<!-- See also the entry for this in func.sgml -->
685
799
<entry><literal><function>pg_backend_pid</function>()</literal></entry>
@@ -726,6 +840,33 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
726
840
</entry>
727
841
</row>
728
842
843
+ <row>
844
+ <entry><literal><function>pg_stat_get_xact_function_calls</function>(<type>oid</type>)</literal></entry>
845
+ <entry><type>bigint</type></entry>
846
+ <entry>
847
+ Number of times the function has been called, in the current transaction.
848
+ </entry>
849
+ </row>
850
+
851
+ <row>
852
+ <entry><literal><function>pg_stat_get_xact_function_time</function>(<type>oid</type>)</literal></entry>
853
+ <entry><type>bigint</type></entry>
854
+ <entry>
855
+ Total wall clock time spent in the function, in microseconds, in the
856
+ current transaction. Includes the time spent in functions called by
857
+ this one.
858
+ </entry>
859
+ </row>
860
+
861
+ <row>
862
+ <entry><literal><function>pg_stat_get_xact_function_self_time</function>(<type>oid</type>)</literal></entry>
863
+ <entry><type>bigint</type></entry>
864
+ <entry>
865
+ Time spent in only this function, in the current transaction. Time
866
+ spent in called functions is excluded.
867
+ </entry>
868
+ </row>
869
+
729
870
<row>
730
871
<entry><literal><function>pg_stat_get_backend_idset</function>()</literal></entry>
731
872
<entry><type>setof integer</type></entry>
0 commit comments