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 $ -->
22
33<chapter id="monitoring">
44 <title>Monitoring Database Activity</title>
@@ -124,8 +124,8 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
124124
125125 <para>
126126 <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+ facilityis independent of the collector process.
129129 </para>
130130
131131 <sect2 id="monitoring-stats-setup">
@@ -165,8 +165,8 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
165165 </para>
166166
167167 <para>
168- The statistics collectorcommunicates with thebackends needing
169- information (including autovacuum) through temporary files.
168+ The statistics collectortransmits thecollected
169+ informationto backends (including autovacuum) through temporary files.
170170 These files are stored in the <filename>pg_stat_tmp</filename> subdirectory.
171171 When the postmaster shuts down, a permanent copy of the statistics
172172 data is stored in the <filename>global</filename> subdirectory. For increased
@@ -219,6 +219,16 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
219219 statistical information will cause a new snapshot to be fetched.
220220 </para>
221221
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+
222232 <table id="monitoring-stats-views-table">
223233 <title>Standard Statistics Views</title>
224234
@@ -299,6 +309,27 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
299309 tables are shown.</entry>
300310 </row>
301311
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+
302333 <row>
303334 <entry><structname>pg_stat_all_indexes</></entry>
304335 <entry>For each index in the current database,
@@ -395,6 +426,13 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
395426 </entry>
396427 </row>
397428
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+
398436 </tbody>
399437 </tgroup>
400438 </table>
@@ -405,7 +443,7 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
405443 </para>
406444
407445 <para>
408- Beginning in <productname>PostgreSQL</productname> 8.1, indexes can be
446+ Indexes can be
409447 used either directly or via <quote>bitmap scans</>. In a bitmap scan
410448 the output of several indexes can be combined via AND or OR rules;
411449 so it is difficult to associate individual heap row fetches
@@ -680,6 +718,82 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
680718 </entry>
681719 </row>
682720
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+
683797 <row>
684798 <!-- See also the entry for this in func.sgml -->
685799 <entry><literal><function>pg_backend_pid</function>()</literal></entry>
@@ -726,6 +840,33 @@ postgres: <replaceable>user</> <replaceable>database</> <replaceable>host</> <re
726840 </entry>
727841 </row>
728842
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+
729870 <row>
730871 <entry><literal><function>pg_stat_get_backend_idset</function>()</literal></entry>
731872 <entry><type>setof integer</type></entry>