Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions doc/src/sgml/monitoring.sgml
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,14 @@ postgres 27093 0.0 0.0 30096 2752 ? Ss 11:34 0:00 postgres: ser
</entry>
</row>

<row>
<entry><structname>pg_stat_wait_event</structname><indexterm><primary>pg_stat_wait_event</primary></indexterm></entry>
<entry>One row per each non custom wait event, showing statistics about wait event activity. See
<link linkend="monitoring-pg-stat-wait-event-view">
<structname>pg_stat_wait_event</structname></link> for details.
</entry>
</row>

<row>
<entry><structname>pg_stat_wal</structname><indexterm><primary>pg_stat_wal</primary></indexterm></entry>
<entry>One row only, showing statistics about WAL activity. See
Expand Down Expand Up @@ -4824,6 +4832,76 @@ description | Waiting for a newly initialized WAL file to reach durable storage

</sect2>

<sect2 id="monitoring-pg-stat-wait-event-view">
<title><structname>pg_stat_wait_event</structname></title>

<indexterm>
<primary>pg_stat_wait_event</primary>
</indexterm>

<para>
The <structname>pg_stat_wait_event</structname> view will contain
one row for each non custom wait event, showing statistics about that wait
event.
</para>

<table id="pg-stat-wait-event-view" xreflabel="pg_stat_wait_event">
<title><structname>pg_stat_wait_event</structname> View</title>
<tgroup cols="1">
<thead>
<row>
<entry role="catalog_table_entry"><para role="column_definition">
Column Type
</para>
<para>
Description
</para></entry>
</row>
</thead>

<tbody>
<row>
<entry role="catalog_table_entry"><para role="column_definition">
<structfield>type</structfield> <type>text</type>
</para>
<para>
Wait event type
</para></entry>
</row>

<row>
<entry role="catalog_table_entry"><para role="column_definition">
<structfield>name</structfield> <type>text</type>
</para>
<para>
Wait event name
</para></entry>
</row>

<row>
<entry role="catalog_table_entry"><para role="column_definition">
<structfield>counts</structfield> <type>bigint</type>
</para>
<para>
Number of times waiting on this wait event
</para></entry>
</row>

<row>
<entry role="catalog_table_entry"><para role="column_definition">
<structfield>stats_reset</structfield> <type>timestamp with time zone</type>
</para>
<para>
Time at which these statistics were last reset
</para></entry>
</row>

</tbody>
</tgroup>
</table>

</sect2>

<sect2 id="monitoring-stats-functions">
<title>Statistics Functions</title>

Expand Down Expand Up @@ -5056,6 +5134,12 @@ description | Waiting for a newly initialized WAL file to reach durable storage
<structname>pg_stat_slru</structname> view.
</para>
</listitem>
<listitem>
<para>
<literal>wait_event</literal>: Reset all the counters shown in the
<structname>pg_stat_wait_event</structname> view.
</para>
</listitem>
<listitem>
<para>
<literal>wal</literal>: Reset all the counters shown in the
Expand Down
2 changes: 1 addition & 1 deletion src/backend/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ parser/gram.h: parser/gram.y
storage/lmgr/lwlocknames.h: storage/lmgr/generate-lwlocknames.pl ../include/storage/lwlocklist.h utils/activity/wait_event_names.txt
$(MAKE) -C storage/lmgr lwlocknames.h

utils/activity/wait_event_types.h: utils/activity/generate-wait_event_types.pl utils/activity/wait_event_names.txt
utils/activity/wait_event_types.h: utils/activity/generate-wait_event_types.pl utils/activity/wait_event_names.txt ../include/storage/lwlocklist.h ../include/utils/wait_classes.h
$(MAKE) -C utils/activity wait_event_types.h pgstat_wait_event.c wait_event_funcs_data.c

# run this unconditionally to avoid needing to know its dependencies here:
Expand Down
9 changes: 9 additions & 0 deletions src/backend/catalog/system_views.sql
Original file line number Diff line number Diff line change
Expand Up @@ -942,6 +942,15 @@ CREATE VIEW pg_stat_slru AS
s.stats_reset
FROM pg_stat_get_slru() s;

CREATE VIEW pg_stat_wait_event AS
SELECT
s.type,
s.name,
s.counts,
s.total_time,
s.stats_reset
FROM pg_stat_get_wait_event() s;

CREATE VIEW pg_stat_wal_receiver AS
SELECT
s.pid,
Expand Down
5 changes: 3 additions & 2 deletions src/backend/utils/activity/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ OBJS = \
pgstat_shmem.o \
pgstat_slru.o \
pgstat_subscription.o \
pgstat_waitevent.o \
pgstat_wal.o \
pgstat_xact.o \
wait_event.o \
Expand All @@ -45,8 +46,8 @@ wait_event.o: pgstat_wait_event.c
pgstat_wait_event.c: wait_event_types.h
touch $@

wait_event_types.h: $(top_srcdir)/src/backend/utils/activity/wait_event_names.txt generate-wait_event_types.pl
$(PERL) $(srcdir)/generate-wait_event_types.pl --code $<
wait_event_types.h: $(top_srcdir)/src/backend/utils/activity/wait_event_names.txt $(top_srcdir)/src/include/storage/lwlocklist.h $(top_srcdir)/src/include/utils/wait_classes.h generate-wait_event_types.pl
$(PERL) $(srcdir)/generate-wait_event_types.pl --code $(wordlist 1,3,$^)

clean:
rm -f wait_event_types.h pgstat_wait_event.c wait_event_funcs_data.c
Loading
Loading