4
4
<title>pg_wait_sampling</title>
5
5
<para>
6
6
<filename>pg_wait_sampling</filename> is a <productname>&productname;</productname> extension for
7
- collecting sampling-based statistics for wait events.
7
+ collecting sampling-based statistics on wait events.
8
8
</para>
9
9
<para>
10
- Starting from the 9.6 version, <productname>PostgreSQL </productname> provides information about
10
+ Starting from the 9.6 version, <productname>&productname; </productname> provides information about
11
11
the current wait events for particular processes. However, to get
12
12
descriptive statistics of the server activity, you have to sample
13
13
wait events multiple times. The
17
17
<listitem>
18
18
<para>
19
19
<emphasis>Waits history</emphasis> — the list of wait events for
20
- recent processes, with timestamps
20
+ recent processes, with timestamps.
21
21
</para>
22
22
</listitem>
23
23
<listitem>
24
24
<para>
25
- <emphasis>Waits profile</emphasis> — the number wait event samples for all processes over time, per wait event type
25
+ <emphasis>Waits profile</emphasis> — the number of wait event samples for all processes over time, per wait event type.
26
26
</para>
27
27
</listitem>
28
28
<listitem>
29
29
<para>
30
30
Current wait events for all processes, including background
31
- workers
31
+ workers.
32
32
</para>
33
33
</listitem>
34
34
</itemizedlist>
38
38
what a particular process is waiting for at each moment of time, and
39
39
analyze wait events statistics. For the list of possible wait
40
40
events, see
41
- <xref linkend="wait-event-table">
41
+ <xref linkend="wait-event-table">.
42
42
</para>
43
43
<para>
44
44
<emphasis role="strong">See Also</emphasis></para>
50
50
<title>Installation</title>
51
51
<para>The <filename>pg_wait_sampling</filename> extension is included into <productname>&productname;</productname> and requires no special prerequisites.</para>
52
52
<para>
53
- To complete the <filename>pg_wait_sampling</filename> installation :
53
+ To enable <filename>pg_wait_sampling</filename>, do the following :
54
54
</para>
55
55
<orderedlist>
56
56
<listitem>
@@ -65,15 +65,11 @@ shared_preload_libraries = 'pg_wait_sampling'
65
65
</listitem>
66
66
<listitem>
67
67
<para>
68
- From the command line, run the following query:
68
+ Create the <filename>pg_wait_sampling</filename> extension using the following query:
69
69
</para>
70
70
<programlisting>
71
- $ psql -d <replaceable>dbname</replaceable> -c " CREATE EXTENSION pg_wait_sampling;" ;
71
+ CREATE EXTENSION pg_wait_sampling;
72
72
</programlisting>
73
- <para>
74
- where <replaceable>dbname</replaceable> is the name of the database
75
- for which you would like to use <filename>pg_wait_sampling</filename>.
76
- </para>
77
73
</listitem>
78
74
<listitem>
79
75
<para>
@@ -110,16 +106,14 @@ $ psql -d <replaceable>dbname</replaceable> -c "CREATE EXTENSION pg_wait_sa
110
106
<literal>pg_wait_sampling_current</literal> view:
111
107
</para>
112
108
<programlisting>
113
- CREATE VIEW pg_wait_sampling_current AS
114
- SELECT * FROM pg_wait_sampling_get_current();
109
+ SELECT * FROM pg_wait_sampling_get_current;
115
110
</programlisting>
116
111
<para>
117
112
The returned statistics covers all the active processes,
118
113
including background workers. To filter the view for a single
119
114
process, run <function>pg_wait_sampling_get_current()</function> function specifying the process ID:
120
115
</para>
121
116
<programlisting>
122
- CREATE VIEW pg_wait_sampling_current AS
123
117
SELECT * FROM pg_wait_sampling_get_current(<replaceable>pid</replaceable>);
124
118
</programlisting>
125
119
<para>
@@ -128,13 +122,11 @@ SELECT * FROM pg_wait_sampling_get_current(<replaceable>pid</replaceable>);
128
122
that provides the wait events history for the latest processes:
129
123
</para>
130
124
<programlisting>
131
- CREATE VIEW pg_wait_sampling_history AS
132
- SELECT * FROM pg_wait_sampling_get_history();
125
+ SELECT * FROM pg_wait_sampling_get_history;
133
126
</programlisting>
134
127
<para>
135
128
The returned view displays wait samples per process, with event timestamps. Waits history is implemented as an in-memory ring buffer. By
136
- default, the history size is limited to 5000 samples. If you
137
- would like to save history for a longer period of time, you can
129
+ default, the history size is limited to 5000 samples. To save history for a longer period of time, you can
138
130
modify the <varname>pg_wait_sampling.history_size</varname>
139
131
variable, or connect a client application to periodically read
140
132
waits history and dump it to a local storage.
@@ -144,8 +136,7 @@ SELECT * FROM pg_wait_sampling_get_history();
144
136
<literal>pg_wait_sampling_profile</literal> view:
145
137
</para>
146
138
<programlisting>
147
- CREATE VIEW pg_wait_sampling_profile AS
148
- SELECT * FROM pg_wait_sampling_get_profile();
139
+ SELECT * FROM pg_wait_sampling_get_profile;
149
140
</programlisting>
150
141
<para>
151
142
Waits profile is stored as an in-memory hash table that
@@ -161,10 +152,10 @@ SELECT * FROM pg_wait_sampling_get_profile();
161
152
waits profile from time to time to avoid memory overflow.</para>
162
153
</important>
163
154
<para>
164
- If you are are not interested in the distribution of wait events
155
+ If you are not interested in the distribution of wait events
165
156
between processes, you can set the
166
157
<varname>pg_wait_sampling.profile_pid</varname> variable to
167
- false. In this case, the <literal>pid</literal> value for each
158
+ <literal> false</literal> . In this case, the <literal>pid</literal> value for each
168
159
process is set to zero, and wait samples for all the processes
169
160
are stored together.
170
161
</para>
@@ -229,16 +220,16 @@ SELECT * FROM pg_wait_sampling_get_profile();
229
220
</indexterm>
230
221
</term>
231
222
<listitem>
232
- <para>Sampling mode for waits profile. If set to true, waits
223
+ <para>Sampling mode for waits profile. If set to <literal> true</literal> , waits
233
224
profile is collected per process. If you set
234
225
<literal>pg_wait_sampling.profile_pid</literal> to
235
- false, the sampling profile is collected for all
226
+ <literal> false</literal>, waits profile is collected for all
236
227
processes together. In this case, the
237
228
<literal>pid</literal> value for each process is set to
238
229
zero, and the corresponding row contains wait samples
239
230
for all the processes.
240
231
</para>
241
- <para>Default: true
232
+ <para>Default: <literal> true</literal>
242
233
</para>
243
234
</listitem>
244
235
</varlistentry>
@@ -252,7 +243,7 @@ SELECT * FROM pg_wait_sampling_get_profile();
252
243
<sect4 id="pg-wait-sampling-current-view">
253
244
<title>pg_wait_sampling_current View</title>
254
245
<para>
255
- The <literal >pg_wait_sampling_current</literal > view provides
246
+ The <structname >pg_wait_sampling_current</structname > view provides
256
247
the information about the current wait events for all
257
248
processes, including background workers.
258
249
</para>
@@ -313,7 +304,7 @@ SELECT * FROM pg_wait_sampling_get_profile();
313
304
<sect4 id="pg-wait-sampling-history-view">
314
305
<title>pg_wait_sampling_history View</title>
315
306
<para>
316
- The <literal >pg_wait_sampling_history</literal > view provides
307
+ The <structname >pg_wait_sampling_history</structname > view provides
317
308
the history of wait events. This data is stored as an
318
309
in-memory ring buffer.
319
310
</para>
@@ -385,7 +376,7 @@ SELECT * FROM pg_wait_sampling_get_profile();
385
376
<sect4 id="pg-wait-sampling-profile-view">
386
377
<title>pg_wait_sampling_profile View</title>
387
378
<para>
388
- The <literal >pg_wait_sampling_profile</literal > view provides
379
+ The <structname >pg_wait_sampling_profile</structname > view provides
389
380
the profile of wait events. This data is stored as an
390
381
in-memory hash table.
391
382
</para>
@@ -447,7 +438,7 @@ SELECT * FROM pg_wait_sampling_get_profile();
447
438
<type>text</type>
448
439
</entry>
449
440
<entry>
450
- Count of samples
441
+ Number of samples
451
442
</entry>
452
443
</row>
453
444
</tbody>
@@ -471,20 +462,6 @@ SELECT * FROM pg_wait_sampling_get_profile();
471
462
</itemizedlist></listitem>
472
463
</varlistentry>
473
464
<varlistentry>
474
- <term><function>pg_wait_sampling_get_history()</function>
475
- <indexterm><primary><function>pg_wait_sampling_get_history</></primary>
476
- </indexterm>
477
- </term>
478
- <listitem><para>Returns the <literal>pg_wait_sampling_history</literal> view with the list of wait events for recent processes, with timestamps.</para></listitem>
479
- </varlistentry>
480
- <varlistentry>
481
- <term><function>pg_wait_sampling_get_profile()</function>
482
- <indexterm><primary><function>pg_wait_sampling_get_profile</function></primary>
483
- </indexterm>
484
- </term>
485
- <listitem><para>Returns the profile of wait events.</para></listitem>
486
- </varlistentry>
487
- <varlistentry>
488
465
<term><function>pg_wait_sampling_reset_profile()</function>
489
466
<indexterm><primary><function>pg_wait_sampling_reset_profile</function></primary>
490
467
</indexterm>
0 commit comments