1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-27 12:41:57 +03:00

Track IO times in pg_stat_io

a9c70b46db and 8aaa04b32S added counting of IO operations to a new view,
pg_stat_io. Now, add IO timing for reads, writes, extends, and fsyncs to
pg_stat_io as well.

This combines the tracking for pgBufferUsage with the tracking for pg_stat_io
into a new function pgstat_count_io_op_time(). This should make it a bit
easier to avoid the somewhat costly instr_time conversion done for
pgBufferUsage.

Author: Melanie Plageman <melanieplageman@gmail.com>
Reviewed-by: Andres Freund <andres@anarazel.de>
Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://postgr.es/m/flat/CAAKRu_ay5iKmnbXZ3DsauViF3eMxu4m1oNnJXqV_HyqYeg55Ww%40mail.gmail.com
This commit is contained in:
Andres Freund
2023-04-07 16:05:26 -07:00
parent 1c453cfd89
commit ac8d53dae5
11 changed files with 276 additions and 108 deletions

View File

@ -3814,6 +3814,18 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
</entry>
</row>
<row>
<entry role="catalog_table_entry">
<para role="column_definition">
<structfield>read_time</structfield> <type>double precision</type>
</para>
<para>
Time spent in read operations in milliseconds (if
<xref linkend="guc-track-io-timing"/> is enabled, otherwise zero)
</para>
</entry>
</row>
<row>
<entry role="catalog_table_entry">
<para role="column_definition">
@ -3826,6 +3838,18 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
</entry>
</row>
<row>
<entry role="catalog_table_entry">
<para role="column_definition">
<structfield>write_time</structfield> <type>double precision</type>
</para>
<para>
Time spent in write operations in milliseconds (if
<xref linkend="guc-track-io-timing"/> is enabled, otherwise zero)
</para>
</entry>
</row>
<row>
<entry role="catalog_table_entry">
<para role="column_definition">
@ -3838,6 +3862,18 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
</entry>
</row>
<row>
<entry role="catalog_table_entry">
<para role="column_definition">
<structfield>extend_time</structfield> <type>double precision</type>
</para>
<para>
Time spent in extend operations in milliseconds (if
<xref linkend="guc-track-io-timing"/> is enabled, otherwise zero)
</para>
</entry>
</row>
<row>
<entry role="catalog_table_entry">
<para role="column_definition">
@ -3913,6 +3949,18 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
</entry>
</row>
<row>
<entry role="catalog_table_entry">
<para role="column_definition">
<structfield>fsync_time</structfield> <type>double precision</type>
</para>
<para>
Time spent in fsync operations in milliseconds (if
<xref linkend="guc-track-io-timing"/> is enabled, otherwise zero)
</para>
</entry>
</row>
<row>
<entry role="catalog_table_entry">
<para role="column_definition">
@ -3978,6 +4026,17 @@ SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event i
</itemizedlist>
</para>
<note>
<para>
Columns tracking I/O time will only be non-zero when
<xref linkend="guc-track-io-timing"/> is enabled. The user should be
careful when referencing these columns in combination with their
corresponding IO operations in case <varname>track_io_timing</varname>
was not enabled for the entire time since the last stats reset.
</para>
</note>
</sect2>