@@ -31,7 +31,7 @@ When `pg_wait_sampling` is enabled, it collects two kinds of statistics.
31
31
a client who periodically reads this history and dumps it somewhere, user
32
32
can have continuous history of wait events.
33
33
* Waits profile. It's implemented as in-memory hash table where samples
34
- are accumulated per each wait event and can be divided by process,
34
+ are accumulated per each wait event and can be divided by process, wait event,
35
35
query and other dimensions. This hash table can be reset by user request.
36
36
Assuming there is a client who periodically dumps profile and resets it,
37
37
user can have statistics of wait events over time.
99
99
` pg_wait_sampling_current ` view – information about current wait events for
100
100
all processes including background workers.
101
101
102
- | Column name | Column type | Description |
103
- | ----------- | ----------- | ----------------------- |
104
- | pid | int4 | Id of process |
105
- | event_type | text | Name of wait event type |
106
- | event | text | Name of wait event |
107
- | queryid | int8 | Id of query |
108
-
109
- ` pg_wait_sampling_get_current(pid int4) ` returns the same table for single given
110
- process.
111
-
112
- ` pg_wait_sampling_current_extended ` view – information about current wait events for
113
- all processes including background workers. Structure of this view can be changed
114
- between verions.
115
-
116
102
| Column name | Column type | Description |
117
103
| ------------------- | ----------- | --------------------------- |
118
104
| pid | int4 | Id of process |
@@ -129,28 +115,15 @@ between verions.
129
115
| client_hostname | text | Client hostname |
130
116
| appname | text | Application name |
131
117
132
- ` pg_wait_sampling_get_current_extended (pid int4)` returns the same table for single given
118
+ ` pg_wait_sampling_get_current (pid int4)` returns the same table for single given
133
119
process.
134
120
135
121
` pg_wait_sampling_history ` view – history of wait events obtained by sampling into
136
122
in-memory ring buffer.
137
123
138
- | Column name | Column type | Description |
139
- | ----------- | ----------- | ----------------------- |
140
- | pid | int4 | Id of process |
141
- | ts | timestamptz | Sample timestamp |
142
- | event_type | text | Name of wait event type |
143
- | event | text | Name of wait event |
144
- | queryid | int8 | Id of query |
145
-
146
- ` pg_wait_sampling_history_extended ` view – history of wait events obtained by
147
- sampling into in-memory ring buffer. Structure of this view can be changed
148
- between verions
149
-
150
124
| Column name | Column type | Description |
151
125
| ------------------- | ----------- | --------------------------- |
152
126
| pid | int4 | Id of process |
153
- | ts | timestamptz | Sample timestamp |
154
127
| event_type | text | Name of wait event type |
155
128
| event | text | Name of wait event |
156
129
| queryid | int8 | Id of query |
@@ -163,22 +136,13 @@ between verions
163
136
| client_addr | text | Client address |
164
137
| client_hostname | text | Client hostname |
165
138
| appname | text | Application name |
139
+ | ts | timestamptz | Sample timestamp |
140
+
141
+ ` pg_wait_sampling_reset_history() ` function resets the history.
166
142
167
143
` pg_wait_sampling_profile ` view – profile of wait events obtained by sampling into
168
144
in-memory hash table.
169
145
170
- | Column name | Column type | Description |
171
- | ----------- | ----------- | ----------------------- |
172
- | pid | int4 | Id of process |
173
- | event_type | text | Name of wait event type |
174
- | event | text | Name of wait event |
175
- | queryid | int8 | Id of query |
176
- | count | int8 | Count of samples |
177
-
178
- ` pg_wait_sampling_profile_extended ` view – history of wait events obtained by
179
- sampling into in-memory ring buffer. Structure of this view can be changed
180
- between verions
181
-
182
146
| Column name | Column type | Description |
183
147
| ------------------- | ----------- | --------------------------- |
184
148
| pid | int4 | Id of process |
@@ -201,16 +165,16 @@ between verions
201
165
The work of wait event statistics collector worker is controlled by following
202
166
GUCs.
203
167
204
- | Parameter name | Data type | Description | Default value |
205
- | -------------------------------------| --------- | ---------------------------------------------| --------------: |
206
- | pg_wait_sampling.history_size | int4 | Size of history in-memory ring buffer | 5000 |
207
- | pg_wait_sampling.history_period | int4 | Period for history sampling in milliseconds | 10 |
208
- | pg_wait_sampling.profile_period | int4 | Period for profile sampling in milliseconds | 10 |
209
- | pg_wait_sampling.profile_pid | bool | Whether profile should be per pid | true |
210
- | pg_wait_sampling.profile_queries | enum | Whether profile should be per query | top |
211
- | pg_wait_sampling.sample_cpu | bool | Whether on CPU backends should be sampled | true |
212
- | pg_wait_sampling.history_dimensions | text | Additional columns in extended history view | 'none ' |
213
- | pg_wait_sampling.profile_dimensions | text | Additional columns in extended profile view | 'none ' |
168
+ | Parameter name | Data type | Description | Default value |
169
+ | -------------------------------------| --------- | ---------------------------------------------| ---------------------------------------------- |
170
+ | pg_wait_sampling.history_size | int4 | Size of history in-memory ring buffer | 5000 |
171
+ | pg_wait_sampling.history_period | int4 | Period for history sampling in milliseconds | 10 |
172
+ | pg_wait_sampling.profile_period | int4 | Period for profile sampling in milliseconds | 10 |
173
+ | pg_wait_sampling.profile_pid | bool | Whether profile should be per pid | true |
174
+ | pg_wait_sampling.profile_queries | enum | Whether profile should be per query | top |
175
+ | pg_wait_sampling.sample_cpu | bool | Whether on CPU backends should be sampled | true |
176
+ | pg_wait_sampling.history_dimensions | text | Additional columns in extended history view | 'pid, wait_event_type, wait_event, query_id ' |
177
+ | pg_wait_sampling.profile_dimensions | text | Additional columns in extended profile view | 'pid, wait_event_type, wait_event, query_id ' |
214
178
215
179
If ` pg_wait_sampling.profile_pid ` is set to false, sampling profile wouldn't be
216
180
collected in per-process manner. In this case the value of pid could would
@@ -226,10 +190,11 @@ will be NULL.
226
190
227
191
` pg_wait_sampling.history_dimenstions ` and ` pg_wait_sampling.profile_dimensions `
228
192
determine what additional columns will be sampled in ` history/profile_extended `
229
- views. Possible values are ` none ` , ` all ` , ` role_id ` , ` database_id ` ,
230
- ` parallel_leader_pid ` , ` backend_type ` , ` backend_state ` , ` backend_start_time ` ,
231
- ` client_addr ` , ` client_hostname ` , ` appname ` and any combination of column names.
232
- ` none ` and ` all ` cannot be used together with any other values and must be used alone.
193
+ views. Possible values are ` all ` , ` pid ` , ` wait_event_type ` , ` wait_event ` ,
194
+ ` query_id ` , ` role_id ` , ` database_id ` , ` parallel_leader_pid ` , ` backend_type ` ,
195
+ ` backend_state ` , ` backend_start_time ` , ` client_addr ` , ` client_hostname ` ,
196
+ ` appname ` and any combination of column names.
197
+ ` all ` cannot be used together with any other values and must be used alone.
233
198
234
199
> [ !WARNING]
235
200
> Turning on any of the following columns: ` backend_type ` , ` backend_state ` ,
@@ -238,9 +203,13 @@ views. Possible values are `none`, `all`, `role_id`, `database_id`,
238
203
> BackendStatusTable. This is especially noticeable with PostgreSQL 13-16
239
204
240
205
Values of these GUC variables can be changed only in config file or with ALTER SYSTEM.
241
- Then you need to reload server's configuration (such as with pg_reload_conf function)
206
+ Then you need to reload server's configuration (such as with ` pg_reload_conf ` function)
242
207
for changes to take effect.
243
208
209
+ > [ !WARNING]
210
+ > When using ` pg_reload_conf ` you also need to invoke ` pg_wait_sampling_reset_history() `
211
+ > and ` pg_wait_sampling_reset_profile() ` for correct application of new dimensions
212
+
244
213
See
245
214
[ PostgreSQL documentation] ( http://www.postgresql.org/docs/devel/static/monitoring-stats.html#WAIT-EVENT-TABLE )
246
215
for list of possible wait events.
0 commit comments