monitoring-stats.zh.md 117.5 KB
Newer Older
李少辉-开发者's avatar
李少辉-开发者 已提交
1
## 28.2.统计数据采集器
K
KyleZhang 已提交
2

李少辉-开发者's avatar
李少辉-开发者 已提交
3
[28.2.1. 统计信息收集配置](monitoring-stats.html#MONITORING-STATS-SETUP)
茶陵後's avatar
茶陵後 已提交
4

李少辉-开发者's avatar
李少辉-开发者 已提交
5
[28.2.2. 查看统计数据](monitoring-stats.html#MONITORING-STATS-VIEWS)
茶陵後's avatar
茶陵後 已提交
6

李少辉-开发者's avatar
李少辉-开发者 已提交
7
[28.2.3.`pg_统计活动`](monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW)
茶陵後's avatar
茶陵後 已提交
8

李少辉-开发者's avatar
李少辉-开发者 已提交
9
[28.2.4.`pg_stat_复制`](monitoring-stats.html#MONITORING-PG-STAT-REPLICATION-VIEW)
茶陵後's avatar
茶陵後 已提交
10

李少辉-开发者's avatar
李少辉-开发者 已提交
11
[28.2.5.`pg_stat_replication_插槽`](monitoring-stats.html#MONITORING-PG-STAT-REPLICATION-SLOTS-VIEW)
茶陵後's avatar
茶陵後 已提交
12

李少辉-开发者's avatar
李少辉-开发者 已提交
13
[28.2.6.`pg_stat_wal_接收器`](monitoring-stats.html#MONITORING-PG-STAT-WAL-RECEIVER-VIEW)
茶陵後's avatar
茶陵後 已提交
14

李少辉-开发者's avatar
李少辉-开发者 已提交
15
[28.2.7.`pg_stat_订阅`](monitoring-stats.html#MONITORING-PG-STAT-SUBSCRIPTION)
茶陵後's avatar
茶陵後 已提交
16

李少辉-开发者's avatar
李少辉-开发者 已提交
17
[28.2.8.`pg_stat_ssl`](monitoring-stats.html#MONITORING-PG-STAT-SSL-VIEW)
茶陵後's avatar
茶陵後 已提交
18

李少辉-开发者's avatar
李少辉-开发者 已提交
19
[28.2.9.`pg_stat_gssapi`](monitoring-stats.html#MONITORING-PG-STAT-GSSAPI-VIEW)
茶陵後's avatar
茶陵後 已提交
20

李少辉-开发者's avatar
李少辉-开发者 已提交
21
[28.2.10.`pg_stat_archiver`](monitoring-stats.html#MONITORING-PG-STAT-ARCHIVER-VIEW)
茶陵後's avatar
茶陵後 已提交
22

李少辉-开发者's avatar
李少辉-开发者 已提交
23
[28.2.11.`pg_stat_bgwriter`](monitoring-stats.html#MONITORING-PG-STAT-BGWRITER-VIEW)
茶陵後's avatar
茶陵後 已提交
24

李少辉-开发者's avatar
李少辉-开发者 已提交
25
[28.2.12.`pg_stat_wal`](monitoring-stats.html#MONITORING-PG-STAT-WAL-VIEW)
茶陵後's avatar
茶陵後 已提交
26

李少辉-开发者's avatar
李少辉-开发者 已提交
27
[28.2.13.`pg_统计数据库`](monitoring-stats.html#MONITORING-PG-STAT-DATABASE-VIEW)
茶陵後's avatar
茶陵後 已提交
28

李少辉-开发者's avatar
李少辉-开发者 已提交
29
[28.2.14.`pg_统计_数据库_冲突`](monitoring-stats.html#MONITORING-PG-STAT-DATABASE-CONFLICTS-VIEW)
茶陵後's avatar
茶陵後 已提交
30

李少辉-开发者's avatar
李少辉-开发者 已提交
31
[28.2.15.`pg_统计_所有表格`](monitoring-stats.html#MONITORING-PG-STAT-ALL-TABLES-VIEW)
茶陵後's avatar
茶陵後 已提交
32

李少辉-开发者's avatar
李少辉-开发者 已提交
33
[28.2.16.`pg_stat_all_indexes`](monitoring-stats.html#MONITORING-PG-STAT-ALL-INDEXES-VIEW)
茶陵後's avatar
茶陵後 已提交
34

李少辉-开发者's avatar
李少辉-开发者 已提交
35
[28.2.17.`pg_statio_all_tables`](monitoring-stats.html#MONITORING-PG-STATIO-ALL-TABLES-VIEW)
茶陵後's avatar
茶陵後 已提交
36

李少辉-开发者's avatar
李少辉-开发者 已提交
37
[28.2.18.`pg_statio_all_indexes`](monitoring-stats.html#MONITORING-PG-STATIO-ALL-INDEXES-VIEW)
茶陵後's avatar
茶陵後 已提交
38

李少辉-开发者's avatar
李少辉-开发者 已提交
39
[28.2.19.`pg_statio_all_sequences`](monitoring-stats.html#MONITORING-PG-STATIO-ALL-SEQUENCES-VIEW)
茶陵後's avatar
茶陵後 已提交
40

李少辉-开发者's avatar
李少辉-开发者 已提交
41
[28.2.20.`pg_stat_user_functions`](monitoring-stats.html#MONITORING-PG-STAT-USER-FUNCTIONS-VIEW)
茶陵後's avatar
茶陵後 已提交
42

李少辉-开发者's avatar
李少辉-开发者 已提交
43
[28.2.21.`pg_stat_slru`](monitoring-stats.html#MONITORING-PG-STAT-SLRU-VIEW)
茶陵後's avatar
茶陵後 已提交
44 45

[28.2.22. Statistics Functions](monitoring-stats.html#MONITORING-STATS-FUNCTIONS)
K
KyleZhang 已提交
46

李少辉-开发者's avatar
李少辉-开发者 已提交
47
[](<>)
K
KyleZhang 已提交
48

李少辉-开发者's avatar
李少辉-开发者 已提交
49
PostgreSQL's*statistics collector*is a subsystem that supports collection and reporting of information about server activity. Presently, the collector can count accesses to tables and indexes in both disk-block and individual-row terms. It also tracks the total number of rows in each table, and information about vacuum and analyze actions for each table. It can also count calls to user-defined functions and the total time spent in each one.
K
KyleZhang 已提交
50 51 52 53 54

PostgreSQL also supports reporting dynamic information about exactly what is going on in the system right now, such as the exact command currently being executed by other server processes, and which other connections exist in the system. This facility is independent of the collector process.

### 28.2.1. Statistics Collection Configuration

李少辉-开发者's avatar
李少辉-开发者 已提交
55
Since collection of statistics adds some overhead to query execution, the system can be configured to collect or not collect information. This is controlled by configuration parameters that are normally set in`postgresql.conf`. (See[Chapter 20](runtime-config.html)for details about setting configuration parameters.)
K
KyleZhang 已提交
56

李少辉-开发者's avatar
李少辉-开发者 已提交
57
The parameter[track_activities](runtime-config-statistics.html#GUC-TRACK-ACTIVITIES)enables monitoring of the current command being executed by any server process.
K
KyleZhang 已提交
58

李少辉-开发者's avatar
李少辉-开发者 已提交
59
The parameter[track\_计数](runtime-config-statistics.html#GUC-TRACK-COUNTS)控制是否收集有关表和索引访问的统计信息。
K
KyleZhang 已提交
60

李少辉-开发者's avatar
李少辉-开发者 已提交
61
参数[追踪\_职能](runtime-config-statistics.html#GUC-TRACK-FUNCTIONS)可以跟踪用户定义函数的使用情况。
K
KyleZhang 已提交
62

李少辉-开发者's avatar
李少辉-开发者 已提交
63
参数[追踪\_io\_定时](runtime-config-statistics.html#GUC-TRACK-IO-TIMING)启用对块读取和写入时间的监控。
K
KyleZhang 已提交
64

李少辉-开发者's avatar
李少辉-开发者 已提交
65
参数[追踪\_沃尔\_io\_定时](runtime-config-statistics.html#GUC-TRACK-WAL-IO-TIMING)启用对 WAL 写入时间的监控。
K
KyleZhang 已提交
66

李少辉-开发者's avatar
李少辉-开发者 已提交
67
通常这些参数设置在`postgresql.conf`以便它们适用于所有服务器进程,但可以使用[](sql-set.html)命令。(为了防止普通用户对管理员隐藏他们的活动,只允许超级用户更改这些参数`放`.)
K
KyleZhang 已提交
68

李少辉-开发者's avatar
李少辉-开发者 已提交
69
The statistics collector transmits the collected information to other PostgreSQL processes through temporary files. These files are stored in the directory named by the[stats_temp_directory](runtime-config-statistics.html#GUC-STATS-TEMP-DIRECTORY)parameter,`pg_stat_tmp`by default. For better performance,`stats_temp_directory`can be pointed at a RAM-based file system, decreasing physical I/O requirements. When the server shuts down cleanly, a permanent copy of the statistics data is stored in the`pg_stat`subdirectory, so that statistics can be retained across server restarts. When recovery is performed at server start (e.g., after immediate shutdown, server crash, and point-in-time recovery), all statistics counters are reset.
K
KyleZhang 已提交
70 71 72

### 28.2.2. Viewing Statistics

李少辉-开发者's avatar
李少辉-开发者 已提交
73
Several predefined views, listed in[Table 28.1](monitoring-stats.html#MONITORING-STATS-DYNAMIC-VIEWS-TABLE), are available to show the current state of the system. There are also several other views, listed in[Table 28.2](monitoring-stats.html#MONITORING-STATS-VIEWS-TABLE), available to show the results of statistics collection. Alternatively, one can build custom views using the underlying statistics functions, as discussed in[Section 28.2.22](monitoring-stats.html#MONITORING-STATS-FUNCTIONS).
K
KyleZhang 已提交
74

李少辉-开发者's avatar
李少辉-开发者 已提交
75
When using the statistics to monitor collected data, it is important to realize that the information does not update instantaneously. Each individual server process transmits new statistical counts to the collector just before going idle; so a query or transaction still in progress does not affect the displayed totals. Also, the collector itself emits a new report at most once per`PGSTAT_STAT_INTERVAL`milliseconds (500 ms unless altered while building the server). So the displayed information lags behind actual activity. However, current-query information collected by`track_activities`is always up-to-date.
K
KyleZhang 已提交
76

李少辉-开发者's avatar
李少辉-开发者 已提交
77
Another important point is that when a server process is asked to display any of these statistics, it first fetches the most recent report emitted by the collector process and then continues to use this snapshot for all statistical views and functions until the end of its current transaction. So the statistics will show static information as long as you continue the current transaction. Similarly, information about the current queries of all sessions is collected when any such information is first requested within a transaction, and the same information will be displayed throughout the transaction. This is a feature, not a bug, because it allows you to perform several queries on the statistics and correlate the results without worrying that the numbers are changing underneath you. But if you want to see new results with each query, be sure to do the queries outside any transaction block. Alternatively, you can invoke`pg_stat_clear_snapshot`(), which will discard the current transaction's statistics snapshot (if any). The next use of statistical information will cause a new snapshot to be fetched.
K
KyleZhang 已提交
78

李少辉-开发者's avatar
李少辉-开发者 已提交
79
A transaction can also see its own statistics (as yet untransmitted to the collector) in the views`pg_stat_xact_all_tables`,`pg_stat_xact_sys_tables`,`pg_stat_xact_user_tables`, and`pg_stat_xact_user_functions`. These numbers do not act as stated above; instead they update continuously throughout the transaction.
K
KyleZhang 已提交
80

李少辉-开发者's avatar
李少辉-开发者 已提交
81
Some of the information in the dynamic statistics views shown in[Table 28.1](monitoring-stats.html#MONITORING-STATS-DYNAMIC-VIEWS-TABLE)is security restricted. Ordinary users can only see all the information about their own sessions (sessions belonging to a role that they are a member of). In rows about other sessions, many columns will be null. Note, however, that the existence of a session and its general properties such as its sessions user and database are visible to all users. Superusers and members of the built-in role`pg_read_all_stats`(see also[Section 22.5](predefined-roles.html)) can see all the information about all sessions.
K
KyleZhang 已提交
82 83 84

**Table 28.1. Dynamic Statistics Views**

李少辉-开发者's avatar
李少辉-开发者 已提交
85 86 87 88 89 90 91 92 93 94 95 96 97 98
| View Name | Description |
| --------- | ----------- |
| `pg_stat_activity` [](<>) | One row per server process, showing information related to the current activity of that process, such as state and current query. See[`pg_stat_activity`](monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW)for details. |
| `pg_stat_replication`[](<>) | One row per WAL sender process, showing statistics about replication to that sender's connected standby server. See[`pg_stat_replication`](monitoring-stats.html#MONITORING-PG-STAT-REPLICATION-VIEW)for details. |
| `pg_stat_wal_receiver`[](<>) | Only one row, showing statistics about the WAL receiver from that receiver's connected server. See[`pg_stat_wal_receiver`](monitoring-stats.html#MONITORING-PG-STAT-WAL-RECEIVER-VIEW)for details. |
| `pg_stat_subscription`[](<>) | 每个订阅至少一行,显示有关订阅工作者的信息。看[`pg_stat_subscription`](monitoring-stats.html#MONITORING-PG-STAT-SUBSCRIPTION)详情。 |
| `pg_stat_ssl`[](<>) | 每个连接(常规和复制)一行,显示有关此连接上使用的 SSL 的信息。看[`pg_stat_ssl`](monitoring-stats.html#MONITORING-PG-STAT-SSL-VIEW)详情。 |
| `pg_stat_gssapi`[](<>) | 每个连接(常规和复制)一行,显示有关此连接上使用的 GSSAPI 身份验证和加密的信息。看[`pg_stat_gssapi`](monitoring-stats.html#MONITORING-PG-STAT-GSSAPI-VIEW)详情。 |
| `pg_stat_progress_analyze`[](<>) | 每个运行的后端(包括 autovacuum 工作进程)一行`分析`,显示当前进度。看[第 28.4.1 节](progress-reporting.html#ANALYZE-PROGRESS-REPORTING). |
| `pg_stat_progress_create_index`[](<>) | 每个后端运行一行`创建索引`要么`重新索引`,显示当前进度。看[第 28.4.2 节](progress-reporting.html#CREATE-INDEX-PROGRESS-REPORTING). |
| `pg_stat_progress_vacuum`[](<>) | 每个运行的后端(包括 autovacuum 工作进程)一行`真空`,显示当前进度。看[Section 28.4.3](progress-reporting.html#VACUUM-PROGRESS-REPORTING). |
| `pg_stat_progress_cluster`[](<>) | One row for each backend running`CLUSTER`or`VACUUM FULL`, showing current progress. See[Section 28.4.4](progress-reporting.html#CLUSTER-PROGRESS-REPORTING). |
| `pg_stat_progress_basebackup`[](<>) | One row for each WAL sender process streaming a base backup, showing current progress. See[Section 28.4.5](progress-reporting.html#BASEBACKUP-PROGRESS-REPORTING). |
| `pg_stat_progress_copy`[](<>) | One row for each backend running`COPY`, showing current progress. See[Section 28.4.6](progress-reporting.html#COPY-PROGRESS-REPORTING). |
K
KyleZhang 已提交
99 100 101

**Table 28.2. Collected Statistics Views**

李少辉-开发者's avatar
李少辉-开发者 已提交
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
| View Name | Description |
| --------- | ----------- |
| `pg_stat_archiver`[](<>) | One row only, showing statistics about the WAL archiver process's activity. See[`pg_stat_archiver`](monitoring-stats.html#MONITORING-PG-STAT-ARCHIVER-VIEW)for details. |
| `pg_stat_bgwriter`[](<>) | One row only, showing statistics about the background writer process's activity. See[`pg_stat_bgwriter`](monitoring-stats.html#MONITORING-PG-STAT-BGWRITER-VIEW)详情。 |
| `pg_stat_wal`[](<>) | 仅一行,显示有关 WAL 活动的统计信息。看[`pg_stat_wal`](monitoring-stats.html#MONITORING-PG-STAT-WAL-VIEW)详情。 |
| `pg_stat_database`[](<>) | 每个数据库一行,显示数据库范围的统计信息。看[`pg_stat_database`](monitoring-stats.html#MONITORING-PG-STAT-DATABASE-VIEW)详情。 |
| `pg_stat_database_conflicts`[](<>) | 每个数据库一行,显示有关由于与备用服务器上的恢复冲突而取消的查询的数据库范围统计信息。看[`pg_stat_database_conflicts`](monitoring-stats.html#MONITORING-PG-STAT-DATABASE-CONFLICTS-VIEW)详情。 |
| `pg_stat_all_tables`[](<>) | 当前数据库中每个表的一行,显示有关对该特定表的访问的统计信息。看[`pg_stat_all_tables`](monitoring-stats.html#MONITORING-PG-STAT-ALL-TABLES-VIEW)详情。 |
| `pg_stat_sys_tables`[](<>) | 与...一样`pg_stat_all_tables`, 除了只显示系统表。 |
| `pg_stat_user_tables`[](<>) | 与...一样`pg_stat_all_tables`,除了只显示用户表。 |
| `pg_stat_xact_all_tables`[](<>) | 相似`pg_stat_all_tables`,但计算当前事务中迄今为止采取的行动(即*不是*还包括在`pg_stat_all_tables`及相关观点)。此视图中不存在活动行数和死行数以及清理和分析操作的列。 |
| `pg_stat_xact_sys_tables`[](<>) | 如同`pg_stat_xact_all_tables`, 除了只显示系统表。 |
| `pg_stat_xact_user_tables`[](<>) | 如同`pg_stat_xact_all_tables`,除了只显示用户表。 |
| `pg_stat_all_indexes`[](<>) | 当前数据库中每个索引的一行,显示有关对该特定索引的访问的统计信息。看[`pg_stat_all_indexes`](monitoring-stats.html#MONITORING-PG-STAT-ALL-INDEXES-VIEW)详情。 |
| `pg_stat_sys_indexes`[](<>) | 如同`pg_stat_all_indexes`,除了只显示系统表上的索引。 |
| `pg_stat_user_indexes`[](<>) | 如同`pg_stat_all_indexes`,除了只显示用户表上的索引。 |
| `pg_statio_all_tables`[](<>) | 当前数据库中每个表的一行,显示有关该特定表的 I/O 的统计信息。看[`pg_statio_all_tables`](monitoring-stats.html#MONITORING-PG-STATIO-ALL-TABLES-VIEW)详情。 |
| `pg_statio_sys_tables`[](<>) | 如同`pg_statio_all_tables`, 除了只显示系统表。 |
| `pg_statio_user_tables`[](<>) | 与...一样`pg_statio_all_tables`,除了只显示用户表。 |
| `pg_statio_all_indexes`[](<>) | 当前数据库中每个索引的一行,显示有关该特定索引的 I/O 的统计信息。看[`pg_statio_all_indexes`](monitoring-stats.html#MONITORING-PG-STATIO-ALL-INDEXES-VIEW)详情。 |
| `pg_statio_sys_indexes`[](<>) | 与...一样`pg_statio_all_indexes`,除了只显示系统表上的索引。 |
| `pg_statio_user_indexes`[](<>) | 与...一样`pg_statio_all_indexes`,除了只显示用户表上的索引。 |
| `pg_statio_all_sequences`[](<>) | 当前数据库中每个序列的一行,显示有关该特定序列的 I/O 的统计信息。看[`pg_statio_all_sequences`](monitoring-stats.html#MONITORING-PG-STATIO-ALL-SEQUENCES-VIEW)详情。 |
| `pg_statio_sys_sequences`[](<>) | 与...一样`pg_statio_all_sequences`, 除了只显示系统序列。(目前,未定义系统序列,因此该视图始终为空。) |
| `pg_statio_user_sequences`[](<>) | 与...一样`pg_statio_all_sequences`,除了只显示用户序列。 |
| `pg_stat_user_functions`[](<>) | One row for each tracked function, showing statistics about executions of that function. See[`pg_stat_user_functions`](monitoring-stats.html#MONITORING-PG-STAT-USER-FUNCTIONS-VIEW)for details. |
| `pg_stat_xact_user_functions`[](<>) | Similar to`pg_stat_user_functions`, but counts only calls during the current transaction (which are*not*yet included in`pg_stat_user_functions`). |
| `pg_stat_slru`[](<>) | One row per SLRU, showing statistics of operations. See[`pg_stat_slru`](monitoring-stats.html#MONITORING-PG-STAT-SLRU-VIEW)for details. |
| `pg_stat_replication_slots`[](<>) | One row per replication slot, showing statistics about the replication slot's usage. See[`pg_stat_replication_slots`](monitoring-stats.html#MONITORING-PG-STAT-REPLICATION-SLOTS-VIEW)for details. |

The per-index statistics are particularly useful to determine which indexes are being used and how effective they are.

The`pg_statio_`views are primarily useful to determine the effectiveness of the buffer cache. When the number of actual disk reads is much smaller than the number of buffer hits, then the cache is satisfying most read requests without invoking a kernel call. However, these statistics do not give the entire story: due to the way in which PostgreSQL handles disk I/O, data that is not in the PostgreSQL buffer cache might still reside in the kernel's I/O cache, and might therefore still be fetched without requiring a physical read. Users interested in obtaining more detailed information on PostgreSQL I/O behavior are advised to use the PostgreSQL statistics collector in combination with operating system utilities that allow insight into the kernel's handling of I/O.

### 28.2.3.`pg_stat_activity`

[](<>)

The`pg_stat_activity`view will have one row per server process, showing information related to the current activity of that process.

**Table 28.3.`pg_stat_activity`看法**

| 列类型<br/><br/>描述 |
| --------------- |
| `数据` `样的`<br/><br/>此后端连接到的数据库的 OID |
| `数据名` `姓名`<br/><br/>此后端连接到的数据库的名称 |
| `pid` `整数`<br/><br/>此后端的进程 ID |
| `leader_pid` `整数`<br/><br/>并行组负责人的进程 ID,如果此进程是并行查询工作者。`空值`如果这个进程是并行组长或者不参与并行查询。 |
| `使用sysid` `样的`<br/><br/>登录到此后端的用户的 OID |
| `使用名称` `姓名`<br/><br/>登录到此后端的用户名 |
| `应用名称` `文本`<br/><br/>连接到此后端的应用程序的名称 |
| `客户端地址` `网络`<br/><br/>连接到此后端的客户端的 IP 地址。如果此字段为空,则表明客户端通过服务器机器上的 Unix 套接字连接,或者这是一个内部进程,例如 autovacuum。 |
| `客户端主机名` `文本`<br/><br/>已连接客户端的主机名,由反向 DNS 查找报告`客户端地址`.该字段仅对 IP 连接不为空,并且仅当[日志\_主机名](runtime-config-logging.html#GUC-LOG-HOSTNAME)已启用。 |
| `客户端端口` `整数`<br/><br/>客户端用于与此后端通信的 TCP 端口号,或`-1`如果使用 Unix 套接字。如果该字段为空,则表明这是一个内部服务器进程。 |
| `backend_start` `带时区的时间戳`<br/><br/>此过程开始的时间。对于客户端后端,这是客户端连接到服务器的时间。 |
| `xact_start` `带时区的时间戳`<br/><br/>此进程的当前事务开始的时间,如果没有事务处于活动状态,则为 null。如果当前查询是其事务的第一个,则此列等于`查询开始`柱子。 |
| `查询开始` `带时区的时间戳`<br/><br/>当前活动查询开始的时间,或者如果`状态`不是`积极的`, 当最后一个查询开始时 |
| `state_change` `带时区的时间戳`<br/><br/>时间`状态`上次更改 |
| `等待事件类型` `文本`<br/><br/>后端正在等待的事件类型(如果有);否则为空。看[表 28.4](monitoring-stats.html#WAIT-EVENT-TABLE). |
| `等待事件` `文本`<br/><br/>如果后端当前正在等待,则等待事件名称,否则为 NULL。看[表 28.5](monitoring-stats.html#WAIT-EVENT-ACTIVITY-TABLE)通过[表 28.13](monitoring-stats.html#WAIT-EVENT-TIMEOUT-TABLE). |
| `状态` `文本`<br/><br/>此后端的当前整体状态。可能的值为:<br/><br/>* `积极的`:后端正在执行查询。<br/><br/>* `闲`:后端正在等待新的客户端命令。<br/><br/>* `交易闲置`:后端处于事务中,但当前未执行查询。<br/><br/>* `事务中的空闲(中止)`: 这个状态类似于`交易闲置`,但事务中的其中一条语句导致错误除外。<br/><br/>* `快速路径函数调用`:后端正在执行快速路径功能。<br/><br/>* `禁用`:如果出现此状态,则报告此状态[追踪\_活动](runtime-config-statistics.html#GUC-TRACK-ACTIVITIES)在这个后端被禁用。 |
| `backend_xid` `xid`<br/><br/>此后端的顶级事务标识符(如果有)。 |
| `backend_xmin` `xid`<br/><br/>当前后端的`xmin`地平线。 |
| `查询ID` `大整数`<br/><br/>此后端最近查询的标识符。如果`状态``积极的`此字段显示当前正在执行的查询的标识符。在所有其他状态下,它显示最后执行的查询的标识符。默认情况下不计算查询标识符,因此该字段将为空,除非[计算\_询问\_id](runtime-config-statistics.html#GUC-COMPUTE-QUERY-ID)启用参数或配置计算查询标识符的第三方模块。 |
| `询问` `文本`<br/><br/>此后端最近查询的文本。如果`状态``积极的`此字段显示当前正在执行的查询。在所有其他状态下,它显示最后执行的查询。默认情况下,查询文本被截断为 1024 字节;这个值可以通过参数改变[追踪\_活动\_询问\_尺寸](runtime-config-statistics.html#GUC-TRACK-ACTIVITY-QUERY-SIZE). |
| `后端类型` `文本`<br/><br/>当前后端的类型。可能的类型是`自动真空发射器`,`自动吸尘器`,`逻辑复制启动器`,`逻辑复制工作者`,`并行工作者`,`背景作家`,`客户端后端`,`检查指针`,`阿奇弗`,`启动`,`沃尔接收机`,`沃尔森德``沃尔夫作家`。此外,通过扩展注册的背景工作者可能有其他类型。 |

### 笔记

这个`等等``状态`列是独立的。如果后端在`忙碌的`国家,它可能是,也可能不是`等待`在某些事件上。如果州政府`忙碌的``等等`非空,表示正在执行查询,但在系统中的某个位置被阻止。

**表28.4。等待事件类型**

| 等待事件类型 | 描述 |
| ------ | --- |
| `活动` | 服务器进程处于空闲状态。此事件类型表示进程在其主处理循环中等待活动。`等等`将确定具体的等待点;看见[表28.5](monitoring-stats.html#WAIT-EVENT-ACTIVITY-TABLE). |
| `缓冲销` | 服务器进程正在等待对数据缓冲区的独占访问。如果另一个进程持有上次从相关缓冲区读取数据的打开游标,则可以延长缓冲区引脚等待时间。看见[表28.6](monitoring-stats.html#WAIT-EVENT-BUFFERPIN-TABLE). |
| `客户` | 服务器进程正在连接到用户应用程序的套接字上等待活动。因此,服务器期望发生独立于其内部进程的事情。`等等`将确定具体的等待点;看见[表28.7](monitoring-stats.html#WAIT-EVENT-CLIENT-TABLE). |
| `扩大` | 服务器进程正在等待扩展模块定义的某些条件。看见[表28.8](monitoring-stats.html#WAIT-EVENT-EXTENSION-TABLE). |
| `木卫一` | 服务器进程正在等待I/O操作完成。`等等`将确定具体的等待点;看见[表28.9](monitoring-stats.html#WAIT-EVENT-IO-TABLE). |
| `工控机` | 服务器进程正在等待与另一个服务器进程的某些交互。`等等`将确定具体的等待点;看见[表28.10](monitoring-stats.html#WAIT-EVENT-IPC-TABLE). |
| `锁` | 服务器进程正在等待重量级锁。重量级锁,也称为锁管理器锁或简称锁,主要保护 SQL 可见的对象,例如表。但是,它们也用于确保某些内部操作(例如关系扩展)的互斥。`等待事件`将识别等待的锁类型;看[表 28.11](monitoring-stats.html#WAIT-EVENT-LOCK-TABLE). |
| `长锁` | 服务器进程正在等待轻量级锁。大多数此类锁保护共享内存中的特定数据结构。`等待事件`将包含一个标识轻量级锁用途的名称。(一些锁有特定的名称;其他锁属于一组锁,每个锁都有类似的用途。)请参阅表 28.12[.](monitoring-stats.html#WAIT-EVENT-LWLOCK-TABLE)暂停 |
| `服务器进程正在等待超时到期。` | 等待事件`将确定具体的等待点;`看表 28.13[.](monitoring-stats.html#WAIT-EVENT-TIMEOUT-TABLE)表 28.5。 |

**等待类型的事件`活动`**

| `活动`等待事件 | 描述 |
| -------- | --- |
| `存档主` | 在归档进程的主循环中等待。 |
| `AutoVacuumMain` | 在 autovacuum 启动器进程的主循环中等待。 |
| `BgWriter休眠` | 在后台写入进程中等待,正在休眠。 |
| `BgWriterMain` | Waiting in main loop of background writer process. |
| `CheckpointerMain` | Waiting in main loop of checkpointer process. |
| `LogicalApplyMain` | Waiting in main loop of logical replication apply process. |
| `LogicalLauncherMain` | Waiting in main loop of logical replication launcher process. |
| `PgStatMain` | Waiting in main loop of statistics collector process. |
| `RecoveryWalStream` | Waiting in main loop of startup process for WAL to arrive, during streaming recovery. |
| `SysLoggerMain` | Waiting in main loop of syslogger process. |
| `WalReceiverMain` | Waiting in main loop of WAL receiver process. |
| `WalSenderMain` | Waiting in main loop of WAL sender process. |
| `WalWriterMain` | Waiting in main loop of WAL writer process. |

**Table 28.6. Wait Events of Type`BufferPin`**

| `BufferPin`Wait Event | Description |
| --------------------- | ----------- |
| `BufferPin` | Waiting to acquire an exclusive pin on a buffer. |

**Table 28.7. Wait Events of Type`Client`**

| `Client`Wait Event | Description |
| ------------------ | ----------- |
| `ClientRead` | Waiting to read data from the client. |
| `ClientWrite` | Waiting to write data to the client. |
| `GSSOpenServer` | Waiting to read data from the client while establishing a GSSAPI session. |
| `LibPQWalReceiverConnect` | Waiting in WAL receiver to establish connection to remote server. |
| `LibPQWalReceiverReceive` | Waiting in WAL receiver to receive data from remote server. |
| `SSLOpenServer` | Waiting for SSL while attempting connection. |
| `WalSenderWaitForWAL` | Waiting for WAL to be flushed in WAL sender process. |
| `WalSenderWriteData` | Waiting for any activity when processing replies from WAL receiver in WAL sender process. |

**Table 28.8. Wait Events of Type`Extension`**

| `Extension`Wait Event | Description |
| --------------------- | ----------- |
| `Extension` | Waiting in an extension. |

**Table 28.9. Wait Events of Type`IO`**

| `IO`Wait Event | Description |
| -------------- | ----------- |
| `BaseBackupRead` | 等待从文件中读取基本备份。 |
| `BufFileRead` | 等待从缓冲文件中读取。 |
| `BufFileWrite` | 等待写入缓冲文件。 |
| `BufFileTruncate` | 等待缓冲文件被截断。 |
| `控制文件读取` | 等待从`pg_control`文件。 |
| `控制文件同步` | 等待着`pg_control`文件以达到持久存储。 |
| `控制文件同步更新` | 等待更新`pg_control`文件以达到持久存储。 |
| `控制文件写入` | 等待写入`pg_control`文件。 |
| `控制文件写入更新` | 等待写入更新`pg_control`文件。 |
| `复制文件读取` | 在文件复制操作期间等待读取。 |
| `复制文件写入` | 在文件复制操作期间等待写入。 |
| `DSMFFillZeroWrite` | 等待用零填充动态共享内存支持文件。 |
| `数据文件扩展` | 等待扩展关系数据文件。 |
| `数据文件刷新` | 等待关系数据文件到达持久存储。 |
| `数据文件立即同步` | 等待关系数据文件立即同步到持久存储。 |
| `数据文件预取` | 等待来自关系数据文件的异步预取。 |
| `数据文件读取` | 等待从关系数据文件中读取。 |
| `数据文件同步` | 等待对关系数据文件的更改以达到持久存储。 |
| `数据文件截断` | 等待关系数据文件被截断。 |
| `数据文件写入` | 等待写入关系数据文件。 |
| `LockFileAddToDataDirRead` | 在向数据目录锁定文件添加一行时等待读取。 |
| `LockFileAddToDataDirSync` | 等待数据到达持久存储,同时向数据目录锁定文件添加一行。 |
| `LockFileAddToDataDirWrite` | 在向数据目录锁定文件添加一行时等待写入。 |
| `LockFileCreateRead` | 在创建数据目录锁定文件时等待读取。 |
| `LockFileCreateSync` | 在创建数据目录锁定文件时等待数据到达持久存储。 |
| `LockFileCreateWrite` | 在创建数据目录锁定文件时等待写入。 |
| `LockFileReCheckDataDirRead` | 在重新检查数据目录锁定文件期间等待读取。 |
| `逻辑重写检查点同步` | 在检查点期间等待逻辑重写映射到达持久存储。 |
| `逻辑重写映射同步` | 在逻辑重写期间等待映射数据到达持久存储。 |
| `逻辑重写映射写入` | 在逻辑重写期间等待写入映射数据。 |
| `逻辑重写同步` | 等待逻辑重写映射到达持久存储。 |
| `逻辑重写截断` | 在逻辑重写期间等待截断映射数据。 |
| `逻辑重写写入` | 等待写入逻辑重写映射。 |
| `关系图读取` | 等待读取关系映射文件。 |
| `关系映射同步` | 等待关系映射文件到达持久存储。 |
| `关系映射写入` | 等待写入关系映射文件。 |
| `重新排序缓冲区读取` | 在重新排序缓冲区管理期间等待读取。 |
| `重新排序缓冲区写入` | 在重新排序缓冲区管理期间等待写入。 |
| `重新排序逻辑映射读取` | 在重新排序缓冲区管理期间等待读取逻辑映射。 |
| `ReplicationSlotRead` | 等待从复制槽控制文件中读取。 |
| `ReplicationSlotRestoreSync` | 等待复制槽控制文件到达持久存储,同时将其恢复到内存。 |
| `ReplicationSlotSync` | 等待复制槽控制文件到达持久存储。 |
| `复制槽写` | 等待写入复制槽控制文件。 |
| `SLRUFlushSync` | 在检查点或数据库关闭期间等待 SLRU 数据到达持久存储。 |
| `SLRU读取` | 等待读取 SLRU 页。 |
| `SLRU同步` | 在页面写入后等待 SLRU 数据到达持久存储。 |
| `SLRU写` | 等待写入 SLRU 页。 |
| `快照构建读取` | 等待读取序列化的历史目录快照。 |
| `快照构建同步` | 等待序列化的历史目录快照到达持久存储。 |
| `快照构建写入` | 等待写入序列化的历史目录快照。 |
| `时间线历史文件同步` | 等待通过流复制接收到的时间线历史文件到达持久存储。 |
| `时间线历史文件写入` | 等待写入通过流复制接收到的时间线历史文件。 |
| `时间线历史读` | 等待读取时间线历史文件。 |
| `时间线历史同步` | 等待新创建的时间线历史文件到达持久存储。 |
| `时间线历史写` | 等待写入新创建的时间线历史文件。 |
| `双相文件读取` | 等待读取两阶段状态文件。 |
| `双相文件同步` | 等待两阶段状态文件到达持久存储。 |
| `双阶段文件写入` | 等待写入两阶段状态文件。 |
| `WALBootstrapSync` | 在引导期间等待 WAL 到达持久存储。 |
| `WALBootstrapWrite` | 在引导期间等待写入 WAL 页。 |
| `WALCopyRead` | 通过复制现有的 WAL 段创建新的 WAL 段时等待读取。 |
| `WALCopySync` | 等待通过复制现有 WAL 段创建的新 WAL 段到达持久存储。 |
| `WALCopyWrite` | 通过复制现有的 WAL 段创建新的 WAL 段时等待写入。 |
| `WALInitSync` | 等待新初始化的 WAL 文件到达持久存储。 |
| `WALInitWrite` | 在初始化新的 WAL 文件时等待写入。 |
| `沃尔读` | 等待从 WAL 文件中读取。 |
| `WALSenderTimelineHistoryRead` | 在 walsender 时间线命令期间等待从时间线历史文件中读取。 |
| `WALSync` | 等待 WAL 文件到达持久存储。 |
| `WALSync 方法分配` | 在分配新的 WAL 同步方法时等待数据到达持久存储。 |
| `WALWrite` | 等待写入 WAL 文件。 |
| `逻辑更改读取` | Waiting for a read from a logical changes file. |
| `LogicalChangesWrite` | Waiting for a write to a logical changes file. |
| `LogicalSubxactRead` | Waiting for a read from a logical subxact file. |
| `LogicalSubxactWrite` | Waiting for a write to a logical subxact file. |

**Table 28.10. Wait Events of Type`IPC`**

| `IPC`Wait Event | Description |
| --------------- | ----------- |
| `AppendReady` | Waiting for subplan nodes of an`Append`plan node to be ready. |
| `BackendTermination` | Waiting for the termination of another backend. |
| `BackupWaitWalArchive` | Waiting for WAL files required for a backup to be successfully archived. |
| `BgWorkerShutdown` | Waiting for background worker to shut down. |
| `BgWorkerStartup` | Waiting for background worker to start up. |
| `BtreePage` | Waiting for the page number needed to continue a parallel B-tree scan to become available. |
| `BufferIO` | Waiting for buffer I/O to complete. |
| `CheckpointDone` | Waiting for a checkpoint to complete. |
| `检查点开始` | 等待检查点开始。 |
| `执行聚集` | 在执行一个子进程时等待来自一个子进程的活动`收集`计划节点。 |
| `HashBatchAllocate` | Waiting for an elected Parallel Hash participant to allocate a hash table. |
| `HashBatchElect` | 等待选举一个 Parallel Hash 参与者来分配一个哈希表。 |
| `哈希批量加载` | 等待其他并行哈希参与者完成加载哈希表。 |
| `HashBuildAllocate` | 等待选出的 Parallel Hash 参与者分配初始哈希表。 |
| `HashBuildElect` | 等待选举一个并行哈希参与者来分配初始哈希表。 |
| `HashBuildHashInner` | 等待其他并行哈希参与者完成内部关系哈希。 |
| `HashBuildHashOuter` | 等待其他 Parallel Hash 参与者完成对外部关系的划分。 |
| `HashGrowBatchesAllocate` | Waiting for an elected Parallel Hash participant to allocate more batches. |
| `HashGrowBatchesDecide` | 等待选择一个并行哈希参与者来决定未来的批量增长。 |
| `HashGrowBatchesElect` | 等待选举一个 Parallel Hash 参与者来分配更多的批次。 |
| `HashGrowBatches完成` | Waiting for an elected Parallel Hash participant to decide on future batch growth. |
| `HashGrowBatches重新分区` | 等待其他 Parallel Hash 参与者完成重新分区。 |
| `HashGrowBucketsAllocate` | Waiting for an elected Parallel Hash participant to finish allocating more buckets. |
| `HashGrowBucketsElect` | 等待选举一个 Parallel Hash 参与者来分配更多的桶。 |
| `HashGrowBuckets重新插入` | 等待其他并行哈希参与者完成将元组插入新桶。 |
| `逻辑同步数据` | 等待逻辑复制远程服务器发送数据以进行初始表同步。 |
| `逻辑同步状态改变` | 等待逻辑复制远程服务器更改状态。 |
| `消息队列内部` | 等待另一个进程附加到共享消息队列。 |
| `MessageQueuePutMessage` | 等待将协议消息写入共享消息队列。 |
| `消息队列接收` | 等待从共享消息队列接收字节。 |
| `消息队列发送` | 等待将字节发送到共享消息队列。 |
| `并行位图扫描` | 等待并行位图扫描被初始化。 |
| `ParallelCreateIndexScan` | 等待并行`创建索引`工人完成堆扫描。 |
| `并行完成` | 等待并行工作者完成计算。 |
| `ProcArrayGroupUpdate` | 等待组长在并行操作结束时清除事务 ID。 |
| `过程信号屏障` | 等待所有后端处理障碍事件。 |
| `Promote` | Waiting for standby promotion. |
| `RecoveryConflictSnapshot` | Waiting for recovery conflict resolution for a vacuum cleanup. |
| `RecoveryConflictTablespace` | Waiting for recovery conflict resolution for dropping a tablespace. |
| `RecoveryPause` | Waiting for recovery to be resumed. |
| `ReplicationOriginDrop` | Waiting for a replication origin to become inactive so it can be dropped. |
| `ReplicationSlotDrop` | Waiting for a replication slot to become inactive so it can be dropped. |
| `SafeSnapshot` | Waiting to obtain a valid snapshot for a`READ ONLY DEFERRABLE`transaction. |
| `SyncRep` | Waiting for confirmation from a remote server during synchronous replication. |
| `WalReceiverExit` | Waiting for the WAL receiver to exit. |
| `WalReceiverWaitStart` | Waiting for startup process to send initial data for streaming replication. |
| `XactGroupUpdate` | Waiting for the group leader to update transaction status at end of a parallel operation. |

**Table 28.11. Wait Events of Type`Lock`**

| `Lock`Wait Event | Description |
| ---------------- | ----------- |
| `advisory` | Waiting to acquire an advisory user lock. |
| `extend` | Waiting to extend a relation. |
| `frozenid` | Waiting to update`pg_database`.`datfrozenxid`and`pg_database`.`datminmxid`. |
| `object` | Waiting to acquire a lock on a non-relation database object. |
| `page` | Waiting to acquire a lock on a page of a relation. |
| `relation` | Waiting to acquire a lock on a relation. |
| `spectoken` | Waiting to acquire a speculative insertion lock. |
| `transactionid` | Waiting for a transaction to finish. |
| `tuple` | Waiting to acquire a lock on a tuple. |
| `userlock` | Waiting to acquire a user lock. |
| `virtualxid` | Waiting to acquire a virtual transaction ID lock. |

**Table 28.12. Wait Events of Type`长锁`**

| `长锁`等待事件 | 描述 |
| -------- | --- |
| `AddinShmemInit` | 等待管理扩展在共享内存中的空间分配。 |
| `自动归档` | 等待更新`postgresql.auto.conf`文件。 |
| `自动真空` | 等待读取或更新 autovacuum worker 的当前状态。 |
| `自动真空计划` | 等待以确保为 autovacuum 选择的表仍需要清理。 |
| `后台工作者` | 等待读取或更新后台工作状态。 |
| `Btree真空` | 等待读取或更新 B 树索引的真空相关信息。 |
| `缓冲区内容` | 等待访问内存中的数据页。 |
| `缓冲区映射` | 等待将数据块与缓冲池中的缓冲区关联。 |
| `CheckpointerComm` | 等待管理 fsync 请求。 |
| `提交` | 等待读取或更新为事务提交时间戳设置的最后一个值。 |
| `CommitTsBuffer` | 等待提交时间戳 SLRU 缓冲区上的 I/O。 |
| `提交TsSLRU` | 等待访问提交时间戳 SLRU 缓存。 |
| `控制文件` | 等待阅读或更新`pg_control`文件或创建一个新的 WAL 文件。 |
| `动态共享内存控制` | 等待读取或更新动态共享内存分配信息。 |
| `LockFastPath` | 等待读取或更新进程的快速路径锁定信息。 |
| `锁管理器` | 等待读取或更新有关“重量级”锁的信息。 |
| `逻辑RepWorker` | 等待读取或更新逻辑复制工作者的状态。 |
| `MultiXactGen` | 等待读取或更新共享的 multixact 状态。 |
| `MultiXactMemberBuffer` | 等待 multixact 成员 SLRU 缓冲区上的 I/O。 |
| `MultiXactMemberSLRU` | 等待访问 multixact 成员 SLRU 缓存。 |
| `MultiXactOffsetBuffer` | 等待 multixact 偏移 SLRU 缓冲区上的 I/O。 |
| `MultiXactOffsetSLRU` | 等待访问 multixact 偏移 SLRU 缓存。 |
| `MultiXactTruncation` | 等待读取或截断 multixact 信息。 |
| `通知缓冲区` | 在等待 I/O`通知`消息 SLRU 缓冲区。 |
| `通知队列` | 等待阅读或更新`通知`消息。 |
| `通知队列尾` | 等待更新限制`通知`消息存储。 |
| `通知SLRU` | 等待访问`通知`消息 SLRU 缓存。 |
| `OidGen` | 等待分配新的 OID。 |
| `旧快照时间图` | 等待读取或更新旧的快照控制信息。 |
| `并行追加` | 在 Parallel Append 计划执行期间等待选择下一个子计划。 |
| `并行哈希连接` | 在 Parallel Hash Join 计划执行期间等待同步工作程序。 |
| `并行查询DSA` | 等待并行查询动态共享内存分配。 |
| `每会话DSA` | 等待并行查询动态共享内存分配。 |
| `每会话记录类型` | 等待访问有关复合类型的并行查询信息。 |
| `PerSessionRecordTypmod` | 等待访问并行查询的有关标识匿名记录类型的类型修饰符的信息。 |
| `PerXactPredicateList` | 在并行查询期间等待访问当前可序列化事务持有的谓词锁列表。 |
| `谓词锁管理器` | 等待访问可序列化事务使用的谓词锁信息。 |
| `过程数组` | 等待访问共享的每进程数据结构(通常,获取快照或报告会话的事务 ID)。 |
| `关系映射` | 等待阅读或更新`pg_filenode.map`文件(用于跟踪某些系统目录的文件节点分配)。 |
| `RelCacheInit` | 等待阅读或更新`pg_internal.init`关系缓存初始化文件。 |
| `复制起源` | 等待创建、删除或使用复制源。 |
| `复制起源状态` | 等待读取或更新一个复制源的进度。 |
| `复制槽分配` | 等待分配或释放复制槽。 |
| `复制槽控制` | 等待读取或更新复制槽状态。 |
| `复制槽IO` | 等待复制槽上的 I/O。 |
| `串行缓冲区` | 等待可序列化事务冲突 SLRU 缓冲区上的 I/O。 |
| `可序列化的已完成列表` | 等待访问已完成的可序列化事务列表。 |
| `可序列化谓词列表` | 等待访问可序列化事务持有的谓词锁列表。 |
| `可序列化XactHash` | 等待读取或更新有关可序列化事务的信息。 |
| `串行SLRU` | 等待访问可序列化事务冲突 SLRU 缓存。 |
| `SharedTidBitmap` | 在并行位图索引扫描期间等待访问共享 TID 位图。 |
| `SharedTupleStore` | 在并行查询期间等待访问共享元组存储。 |
| `索引` | 等待在共享内存中查找或分配空间。 |
| `SInvalRead` | 等待从共享目录失效队列中检索消息。 |
| `无效写入` | 正在等待将消息添加到共享目录失效队列。 |
| `子传输缓冲区` | 等待子事务 SLRU 缓冲区上的 I/O。 |
| `子transSLRU` | 等待访问子事务 SLRU 缓存。 |
| `同步代表` | 等待读取或更新有关同步复制状态的信息。 |
| `同步扫描` | 等待选择同步表扫描的起始位置。 |
| `表空间创建` | 等待创建或删除表空间。 |
| `双相状态` | 等待读取或更新已准备事务的状态。 |
| `WALBuf映射` | 等待替换 WAL 缓冲区中的页面。 |
| `WAL插入` | 等待将 WAL 数据插入内存缓冲区。 |
| `WALWrite` | 等待 WAL 缓冲区写入磁盘。 |
| `WrapLimitsVacuum` | 等待更新事务 id 和 multixact 消耗的限制。 |
| `XactBuffer` | 正在等待事务状态SLRU缓冲区上的I/O。 |
| `XactSLRU` | 正在等待访问事务状态SLRU缓存。 |
| `XACTR截断` | 等待执行`pg_xact_状态`或者更新可用的最旧事务ID。 |
| `喜来登` | 正在等待分配新的事务ID。 |

### 笔记

扩展可以添加`LWLock`输入中所示的列表[表28.12](monitoring-stats.html#WAIT-EVENT-LWLOCK-TABLE)。在某些情况下,扩展名分配的名称在所有服务器进程中都不可用;所以`LWLock`等待事件可能会报告为“仅”`扩大`“而不是分机指定的名称。

**表28.13。等待类型的事件`暂停`**

| `暂停`等待事件 | 描述 |
| -------- | --- |
| `BaseBackupThrottle` | 限制活动时,在基本备份期间等待。 |
| `PgSleep` | 因为打电话给`pg_睡眠`或者兄弟函数。 |
| `恢复延迟` | 由于延迟设置,正在恢复期间等待应用WAL。 |
| `RecoveryRetrievenRetryInterval` | 当WAL数据无法从任何来源获得时,在恢复期间等待(`普格沃尔`,存档或流)。 |
| `真空延迟` | 在基于成本的真空延迟点等待。 |

以下是如何查看等待事件的示例:
K
KyleZhang 已提交
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902

```
SELECT pid, wait_event_type, wait_event FROM pg_stat_activity WHERE wait_event is NOT NULL;
 pid  | wait_event_type | wait_event
### 28.2.4. `pg_stat_replication`

[]()

 The `pg_stat_replication` view will contain one row per WAL sender process, showing statistics about replication to that sender's connected standby server. Only directly connected standbys are listed; no information is available about downstream standby servers.

**Table 28.14. `pg_stat_replication` View**

|                                                                                                                                                                                                                   Column Type<br/><br/> Description                                                                                                                                                                                                                  |
|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                                                                                                                                                                                                     `pid` `integer`<br/><br/> Process ID of a WAL sender process                                                                                                                                                                                                     |
|                                                                                                                                                                                            `usesysid` `oid`<br/><br/> OID of the user logged into this WAL sender process                                                                                                                                                                                            |
|                                                                                                                                                                                           `usename` `name`<br/><br/> Name of the user logged into this WAL sender process                                                                                                                                                                                            |
|                                                                                                                                                                                   `application_name` `text`<br/><br/> Name of the application that is connected to this WAL sender                                                                                                                                                                                   |
|                                                                                                                                   `client_addr` `inet`<br/><br/> IP address of the client connected to this WAL sender. If this field is null, it indicates that the client is connected via a Unix socket on the server machine.                                                                                                                                    |
|                                                                                               `client_hostname` `text`<br/><br/> Host name of the connected client, as reported by a reverse DNS lookup of `client_addr`. This field will only be non-null for IP connections, and only when [log\_hostname](runtime-config-logging.html#GUC-LOG-HOSTNAME) is enabled.                                                                                               |
|                                                                                                                                                         `client_port` `integer`<br/><br/> TCP port number that the client is using for communication with this WAL sender, or `-1` if a Unix socket is used                                                                                                                                                          |
|                                                                                                                                                             `backend_start` `timestamp with time zone`<br/><br/> Time when this process was started, i.e., when the client connected to this WAL sender                                                                                                                                                              |
|                                                                                                                                                     `backend_xmin` `xid`<br/><br/> This standby's `xmin` horizon reported by [hot\_standby\_feedback](runtime-config-replication.html#GUC-HOT-STANDBY-FEEDBACK).                                                                                                                                                     |
|`state` `text`<br/><br/> Current WAL sender state. Possible values are:<br/><br/>* `startup`: This WAL sender is starting up.<br/><br/>* `catchup`: This WAL sender's connected standby is catching up with the primary.<br/><br/>* `streaming`: This WAL sender is streaming changes after its connected standby server has caught up with the primary.<br/><br/>* `backup`: This WAL sender is sending a backup.<br/><br/>* `stopping`: This WAL sender is stopping.|
|                                                                                                                                                                                         `sent_lsn` `pg_lsn`<br/><br/> Last write-ahead log location sent on this connection                                                                                                                                                                                          |
|                                                                                                                                                                                 `write_lsn` `pg_lsn`<br/><br/> Last write-ahead log location written to disk by this standby server                                                                                                                                                                                  |
|                                                                                                                                                                                 `flush_lsn` `pg_lsn`<br/><br/> Last write-ahead log location flushed to disk by this standby server                                                                                                                                                                                  |
|                                                                                                                                                                           `replay_lsn` `pg_lsn`<br/><br/> Last write-ahead log location replayed into the database on this standby server                                                                                                                                                                            |
|                                                  `write_lag` `interval`<br/><br/> Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written it (but not yet flushed it or applied it). This can be used to gauge the delay that `synchronous_commit` level `remote_write` incurred while committing if this server was configured as a synchronous standby.                                                   |
|                                                        `flush_lag` `interval`<br/><br/> Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written and flushed it (but not yet applied it). This can be used to gauge the delay that `synchronous_commit` level `on` incurred while committing if this server was configured as a synchronous standby.                                                         |
|                                                           `replay_lag` `interval`<br/><br/> Time elapsed between flushing recent WAL locally and receiving notification that this standby server has written, flushed and applied it. This can be used to gauge the delay that `synchronous_commit` level `remote_apply` incurred while committing if this server was configured as a synchronous standby.                                                           |
|                                                                                                                      `sync_priority` `integer`<br/><br/> Priority of this standby server for being chosen as the synchronous standby in a priority-based synchronous replication. This has no effect in a quorum-based synchronous replication.                                                                                                                      |
|      `sync_state` `text`<br/><br/> Synchronous state of this standby server. Possible values are:<br/><br/>* `async`: This standby server is asynchronous.<br/><br/>* `potential`: This standby server is now asynchronous, but can potentially become synchronous if one of current synchronous ones fails.<br/><br/>* `sync`: This standby server is synchronous.<br/><br/>* `quorum`: This standby server is considered as a candidate for quorum standbys.       |
|                                                                                                                                                                            `reply_time` `timestamp with time zone`<br/><br/> Send time of last reply message received from standby server                                                                                                                                                                            |

 The lag times reported in the `pg_stat_replication` view are measurements of the time taken for recent WAL to be written, flushed and replayed and for the sender to know about it. These times represent the commit delay that was (or would have been) introduced by each synchronous commit level, if the remote server was configured as a synchronous standby. For an asynchronous standby, the `replay_lag` column approximates the delay before recent transactions became visible to queries. If the standby server has entirely caught up with the sending server and there is no more WAL activity, the most recently measured lag times will continue to be displayed for a short time and then show NULL.

 Lag times work automatically for physical replication. Logical decoding plugins may optionally emit tracking messages; if they do not, the tracking mechanism will simply display NULL lag.

### Note

 The reported lag times are not predictions of how long it will take for the standby to catch up with the sending server assuming the current rate of replay. Such a system would show similar times while new WAL is being generated, but would differ when the sender becomes idle. In particular, when the standby has caught up completely, `pg_stat_replication` shows the time taken to write, flush and replay the most recent reported WAL location rather than zero as some users might expect. This is consistent with the goal of measuring synchronous commit and transaction visibility delays for recent write transactions. To reduce confusion for users expecting a different model of lag, the lag columns revert to NULL after a short time on a fully replayed idle system. Monitoring systems should choose whether to represent this as missing data, zero or continue to display the last known value.

### 28.2.5. `pg_stat_replication_slots`

[]()

 The `pg_stat_replication_slots` view will contain one row per logical replication slot, showing statistics about its usage.

**Table 28.15. `pg_stat_replication_slots` View**

|                                                                                                                                                                                 Column Type<br/><br/> Description                                                                                                                                                                                |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                                                                                                                                                     `slot_name` `text`<br/><br/> A unique, cluster-wide identifier for the replication slot                                                                                                                                                      |
|                                                              `spill_txns` `bigint`<br/><br/> Number of transactions spilled to disk once the memory used by logical decoding to decode changes from WAL has exceeded `logical_decoding_work_mem`. The counter gets incremented for both top-level transactions and subtransactions.                                                              |
|                                                                    `spill_count` `bigint`<br/><br/> Number of times transactions were spilled to disk while decoding changes from WAL for this slot. This counter is incremented each time a transaction is spilled, and the same transaction may be spilled multiple times.                                                                     |
|                                                 `spill_bytes` `bigint`<br/><br/> Amount of decoded transaction data spilled to disk while performing decoding of changes from WAL for this slot. This and other spill counters can be used to gauge the I/O which occurred during logical decoding and allow tuning `logical_decoding_work_mem`.                                                 |
|`stream_txns` `bigint`<br/><br/> Number of in-progress transactions streamed to the decoding output plugin after the memory used by logical decoding to decode changes from WAL for this slot has exceeded `logical_decoding_work_mem`. Streaming only works with top-level transactions (subtransactions can't be streamed independently), so the counter is not incremented for subtransactions.|
|                                                  `stream_count``bigint`<br/><br/> Number of times in-progress transactions were streamed to the decoding output plugin while decoding changes from WAL for this slot. This counter is incremented each time a transaction is streamed, and the same transaction may be streamed multiple times.                                                  |
|                                                     `stream_bytes``bigint`<br/><br/> Amount of transaction data decoded for streaming in-progress transactions to the decoding output plugin while decoding changes from WAL for this slot. This and other streaming counters for this slot can be used to tune `logical_decoding_work_mem`.                                                     |
|                                                         `total_txns` `bigint`<br/><br/> Number of decoded transactions sent to the decoding output plugin for this slot. This counts top-level transactions only, and is not incremented for subtransactions. Note that this includes the transactions that are streamed and/or spilled.                                                         |
|                                                                              `total_bytes``bigint`<br/><br/> Amount of transaction data decoded for sending transactions to the decoding output plugin while decoding changes from WAL for this slot. Note that this includes data that is streamed and/or spilled.                                                                              |
|                                                                                                                                                `stats_reset` `timestamp with time zone`<br/><br/> Time at which these statistics were last reset                                                                                                                                                 |

### 28.2.6. `pg_stat_wal_receiver`

[]()

 The `pg_stat_wal_receiver` view will contain only one row, showing statistics about the WAL receiver from that receiver's connected server.

**Table 28.16. `pg_stat_wal_receiver` View**

|                                                                                                                                    Column Type<br/><br/> Description                                                                                                                                   |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                                                                                                                    `pid` `integer`<br/><br/> Process ID of the WAL receiver process                                                                                                                    |
|                                                                                                                 `status` `text`<br/><br/> Activity status of the WAL receiver process                                                                                                                  |
|                                                                                                `receive_start_lsn` `pg_lsn`<br/><br/> First write-ahead log location used when WAL receiver is started                                                                                                 |
|                                                                                                    `receive_start_tli` `integer`<br/><br/> First timeline number used when WAL receiver is started                                                                                                     |
|                                                                `written_lsn` `pg_lsn`<br/><br/> Last write-ahead log location already received and written to disk, but not flushed. This should not be used for data integrity checks.                                                                |
|                                                  `flushed_lsn` `pg_lsn`<br/><br/> Last write-ahead log location already received and flushed to disk, the initial value of this field being the first log location used when WAL receiver is started                                                   |
|                                `received_tli` `integer`<br/><br/> Timeline number of last write-ahead log location received and flushed to disk, the initial value of this field being the timeline number of the first log location used when WAL receiver is started                                 |
|                                                                                          `last_msg_send_time` `timestamp with time zone`<br/><br/> Send time of last message received from origin WAL sender                                                                                           |
|                                                                                       `last_msg_receipt_time` `timestamp with time zone`<br/><br/> Receipt time of last message received from origin WAL sender                                                                                        |
|                                                                                                    `latest_end_lsn` `pg_lsn`<br/><br/> Last write-ahead log location reported to origin WAL sender                                                                                                     |
|                                                                                       `latest_end_time` `timestamp with time zone`<br/><br/> Time of last write-ahead log location reported to origin WAL sender                                                                                       |
|                                                                                                              `slot_name` `text`<br/><br/> Replication slot name used by this WAL receiver                                                                                                              |
|`sender_host` `text`<br/><br/> Host of the PostgreSQL instance this WAL receiver is connected to. This can be a host name, an IP address, or a directory path if the connection is via Unix socket. (The path case can be distinguished because it will always be an absolute path, beginning with `/`.)|
|                                                                                              `sender_port` `integer`<br/><br/> Port number of the PostgreSQL instance this WAL receiver is connected to.                                                                                               |
|                                                                                          `conninfo` `text`<br/><br/> Connection string used by this WAL receiver, with security-sensitive fields obfuscated.                                                                                           |

### 28.2.7. `pg_stat_subscription`

[]()

 The `pg_stat_subscription` view will contain one row per subscription for main worker (with null PID if the worker is not running), and additional rows for workers handling the initial data copy of the subscribed tables.

**Table 28.17. `pg_stat_subscription` View**

|                                             Column Type<br/><br/> Description                                            |
|--------------------------------------------------------------------------------------------------------------------------|
|                                     `subid` `oid`<br/><br/> OID of the subscription                                      |
|                                   `subname` `name`<br/><br/> Name of the subscription                                    |
|                         `pid` `integer`<br/><br/> Process ID of the subscription worker process                          |
|       `relid` `oid`<br/><br/> OID of the relation that the worker is synchronizing; null for the main apply worker       |
|    `received_lsn` `pg_lsn`<br/><br/> Last write-ahead log location received, the initial value of this field being 0     |
|   `last_msg_send_time` `timestamp with time zone`<br/><br/> Send time of last message received from origin WAL sender    |
|`last_msg_receipt_time` `timestamp with time zone`<br/><br/> Receipt time of last message received from origin WAL sender |
|             `latest_end_lsn` `pg_lsn`<br/><br/> Last write-ahead log location reported to origin WAL sender              |
|`latest_end_time` `timestamp with time zone`<br/><br/> Time of last write-ahead log location reported to origin WAL sender|

### 28.2.8. `pg_stat_ssl`

[]()

 The `pg_stat_ssl` view will contain one row per backend or WAL sender process, showing statistics about SSL usage on this connection. It can be joined to `pg_stat_activity` or `pg_stat_replication` on the `pid` column to get more details about the connection.

**Table 28.18. `pg_stat_ssl` View**

|                                                                                                                                                 Column Type<br/><br/> Description                                                                                                                                                 |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                                                                                                                              `pid` `integer`<br/><br/> Process ID of a backend or WAL sender process                                                                                                                              |
|                                                                                                                                 `ssl` `boolean`<br/><br/> True if SSL is used on this connection                                                                                                                                  |
|                                                                                                                 `version` `text`<br/><br/> Version of SSL in use, or NULL if SSL is not in use on this connection                                                                                                                 |
|                                                                                                               `cipher` `text`<br/><br/> Name of SSL cipher in use, or NULL if SSL is not in use on this connection                                                                                                                |
|                                                                                                     `bits` `integer`<br/><br/> Number of bits in the encryption algorithm used, or NULL if SSL is not used on this connection                                                                                                     |
|                 `client_dn` `text`<br/><br/> Distinguished Name (DN) field from the client certificate used, or NULL if no client certificate was supplied or if SSL is not in use on this connection. This field is truncated if the DN field is longer than `NAMEDATALEN` (64 characters in a standard build).                  |
|`client_serial` `numeric`<br/><br/> Serial number of the client certificate, or NULL if no client certificate was supplied or if SSL is not in use on this connection. The combination of certificate serial number and certificate issuer uniquely identifies a certificate (unless the issuer erroneously reuses serial numbers).|
|                                                           `issuer_dn` `text`<br/><br/> DN of the issuer of the client certificate, or NULL if no client certificate was supplied or if SSL is not in use on this connection. This field is truncated like `client_dn`.                                                            |

### 28.2.9. `pg_stat_gssapi`

[]()

 The `pg_stat_gssapi` view will contain one row per backend, showing information about GSSAPI usage on this connection. It can be joined to `pg_stat_activity` or `pg_stat_replication` on the `pid` column to get more details about the connection.

**Table 28.19. `pg_stat_gssapi` View**

|                                                                                                           Column Type<br/><br/> Description                                                                                                           |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                                                                                                   `pid` `integer`<br/><br/> Process ID of a backend                                                                                                   |
|                                                                          `gss_authenticated` `boolean`<br/><br/> True if GSSAPI authentication was used for this connection                                                                           |
|`principal` `text`<br/><br/> Principal used to authenticate this connection, or NULL if GSSAPI was not used to authenticate this connection. This field is truncated if the principal is longer than `NAMEDATALEN` (64 characters in a standard build).|
|                                                                                `encrypted` `boolean`<br/><br/> True if GSSAPI encryption is in use on this connection                                                                                 |

### 28.2.10. `pg_stat_archiver`

[]()

 The `pg_stat_archiver` view will always have a single row, containing data about the archiver process of the cluster.

**Table 28.20. `pg_stat_archiver` View**

|                                   Column Type<br/><br/> Description                                   |
|-------------------------------------------------------------------------------------------------------|
|     `archived_count` `bigint`<br/><br/> Number of WAL files that have been successfully archived      |
|         `last_archived_wal` `text`<br/><br/> Name of the last WAL file successfully archived          |
|`last_archived_time` `timestamp with time zone`<br/><br/> Time of the last successful archive operation|
|          `failed_count` `bigint`<br/><br/> Number of failed attempts for archiving WAL files          |
|     `last_failed_wal` `text`<br/><br/> Name of the WAL file of the last failed archival operation     |
|  `last_failed_time` `timestamp with time zone`<br/><br/> Time of the last failed archival operation   |
|   `stats_reset` `timestamp with time zone`<br/><br/> Time at which these statistics were last reset   |

### 28.2.11. `pg_stat_bgwriter`

[]()

 The `pg_stat_bgwriter` view will always have a single row, containing global data for the cluster.

**Table 28.21. `pg_stat_bgwriter` View**

|                                                                                Column Type<br/><br/> Description                                                                               |
|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                                                `checkpoints_timed` `bigint`<br/><br/> Number of scheduled checkpoints that have been performed                                                 |
|                                                 `checkpoints_req` `bigint`<br/><br/> Number of requested checkpoints that have been performed                                                  |
|     `checkpoint_write_time` `double precision`<br/><br/> Total amount of time that has been spent in the portion of checkpoint processing where files are written to disk, in milliseconds     |
|   `checkpoint_sync_time` `double precision`<br/><br/> Total amount of time that has been spent in the portion of checkpoint processing where files are synchronized to disk, in milliseconds   |
|                                                      `buffers_checkpoint` `bigint`<br/><br/> Number of buffers written during checkpoints                                                      |
|                                                     `buffers_clean` `bigint`<br/><br/> Number of buffers written by the background writer                                                      |
|                          `maxwritten_clean` `bigint`<br/><br/> Number of times the background writer stopped a cleaning scan because it had written too many buffers                           |
|                                                      `buffers_backend` `bigint`<br/><br/> Number of buffers written directly by a backend                                                      |
|`buffers_backend_fsync` `bigint`<br/><br/> Number of times a backend had to execute its own `fsync` call (normally the background writer handles those even when the backend does its own write)|
|                                                                 `buffers_alloc` `bigint`<br/><br/> Number of buffers allocated                                                                 |
|                                               `stats_reset` `timestamp with time zone`<br/><br/> Time at which these statistics were last reset                                                |

### 28.2.12. `pg_stat_wal`

[]()

 The `pg_stat_wal` view will always have a single row, containing data about WAL activity of the cluster.

**Table 28.22. `pg_stat_wal` View**

|                                                                                                                                                                                                 Column Type<br/><br/> Description                                                                                                                                                                                                 |
|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                                                                                                                                                                              `wal_records` `bigint`<br/><br/> Total number of WAL records generated                                                                                                                                                                               |
|                                                                                                                                                                            `wal_fpi` `bigint`<br/><br/> Total number of WAL full page images generated                                                                                                                                                                            |
|                                                                                                                                                                              `wal_bytes` `numeric`<br/><br/> Total amount of WAL generated in bytes                                                                                                                                                                               |
|                                                                                                                                                        `wal_buffers_full` `bigint`<br/><br/> Number of times WAL data was written to disk because WAL buffers became full                                                                                                                                                         |
|                                                                                                     `wal_write` `bigint`<br/><br/> Number of times WAL buffers were written out to disk via `XLogWrite` request. See [Section 30.5](wal-configuration.html) for more information about the internal WAL function `XLogWrite`.                                                                                                     |
|`wal_sync` `bigint`<br/><br/> Number of times WAL files were synced to disk via `issue_xlog_fsync` request (if [fsync](runtime-config-wal.html#GUC-FSYNC) is `on` and [wal\_sync\_method](runtime-config-wal.html#GUC-WAL-SYNC-METHOD) is either `fdatasync`, `fsync` or `fsync_writethrough`, otherwise zero). See [Section 30.5](wal-configuration.html) for more information about the internal WAL function `issue_xlog_fsync`.|
|                                   `wal_write_time` `double precision`<br/><br/> Total amount of time spent writing WAL buffers to disk via `XLogWrite` request, in milliseconds (if [track\_wal\_io\_timing](runtime-config-statistics.html#GUC-TRACK-WAL-IO-TIMING) is enabled, otherwise zero). This includes the sync time when `wal_sync_method` is either `open_datasync` or `open_sync`.                                    |
|                                                              `wal_sync_time` `double precision`<br/><br/> Total amount of time spent syncing WAL files to disk via `issue_xlog_fsync` request, in milliseconds (if `track_wal_io_timing` is enabled, `fsync` is `on`, and `wal_sync_method` is either `fdatasync`, `fsync` or `fsync_writethrough`, otherwise zero).                                                              |
|                                                                                                                                                                 `stats_reset` `timestamp with time zone`<br/><br/> Time at which these statistics were last reset                                                                                                                                                                 |

### 28.2.13. `pg_stat_database`

[]()

 The `pg_stat_database` view will contain one row for each database in the cluster, plus one for shared objects, showing database-wide statistics.

**Table 28.23. `pg_stat_database` View**

|                                                                                                                                       Column Type<br/><br/> Description                                                                                                                                      |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                                                                                                        `datid` `oid`<br/><br/> OID of this database, or 0 for objects belonging to a shared relation                                                                                                         |
|                                                                                                               `datname` `name`<br/><br/> Name of this database, or `NULL` for shared objects.                                                                                                                |
|              `numbackends` `integer`<br/><br/> Number of backends currently connected to this database, or `NULL` for shared objects. This is the only column in this view that returns a value reflecting current state; all other columns return the accumulated values since the last reset.              |
|                                                                                                      `xact_commit` `bigint`<br/><br/> Number of transactions in this database that have been committed                                                                                                       |
|                                                                                                    `xact_rollback` `bigint`<br/><br/> Number of transactions in this database that have been rolled back                                                                                                     |
|                                                                                                                  `blks_read` `bigint`<br/><br/> Number of disk blocks read in this database                                                                                                                  |
|                                  `blks_hit` `bigint`<br/><br/> Number of times disk blocks were found already in the buffer cache, so that a read was not necessary (this only includes hits in the PostgreSQL buffer cache, not the operating system's file system cache)                                   |
|                                                                                                            `tup_returned` `bigint`<br/><br/> Number of rows returned by queries in this database                                                                                                             |
|                                                                                                             `tup_fetched` `bigint`<br/><br/> Number of rows fetched by queries in this database                                                                                                              |
|                                                                                                            `tup_inserted` `bigint`<br/><br/> Number of rows inserted by queries in this database                                                                                                             |
|                                                                                                             `tup_updated` `bigint`<br/><br/> Number of rows updated by queries in this database                                                                                                              |
|                                                                                                             `tup_deleted` `bigint`<br/><br/> Number of rows deleted by queries in this database                                                                                                              |
|                   `conflicts` `bigint`<br/><br/> Number of queries canceled due to conflicts with recovery in this database. (Conflicts occur only on standby servers; see [`pg_stat_database_conflicts`](monitoring-stats.html#MONITORING-PG-STAT-DATABASE-CONFLICTS-VIEW) for details.)                    |
|`temp_files` `bigint`<br/><br/> Number of temporary files created by queries in this database. All temporary files are counted, regardless of why the temporary file was created (e.g., sorting or hashing), and regardless of the [log\_temp\_files](runtime-config-logging.html#GUC-LOG-TEMP-FILES) setting.|
|      `temp_bytes` `bigint`<br/><br/> Total amount of data written to temporary files by queries in this database. All temporary files are counted, regardless of why the temporary file was created, and regardless of the [log\_temp\_files](runtime-config-logging.html#GUC-LOG-TEMP-FILES) setting.       |
|                                                                                                                 `deadlocks` `bigint`<br/><br/> Number of deadlocks detected in this database                                                                                                                 |
|                                                                  `checksum_failures` `bigint`<br/><br/> Number of data page checksum failures detected in this database (or on a shared object), or NULL if data checksums are not enabled.                                                                  |
|                                               `checksum_last_failure` `timestamp with time zone`<br/><br/> Time at which the last data page checksum failure was detected in this database (or on a shared object), or NULL if data checksums are not enabled.                                               |
|                                    `blk_read_time` `double precision`<br/><br/> Time spent reading data file blocks by backends in this database, in milliseconds (if [track\_io\_timing](runtime-config-statistics.html#GUC-TRACK-IO-TIMING) is enabled, otherwise zero)                                    |
|                                   `blk_write_time` `double precision`<br/><br/> Time spent writing data file blocks by backends in this database, in milliseconds (if [track\_io\_timing](runtime-config-statistics.html#GUC-TRACK-IO-TIMING) is enabled, otherwise zero)                                    |
|                  `session_time` `double precision`<br/><br/> Time spent by database sessions in this database, in milliseconds (note that statistics are only updated when the state of a session changes, so if sessions have been idle for a long time, this idle time won't be included)                  |
|                   `active_time` `double precision`<br/><br/> Time spent executing SQL statements in this database, in milliseconds (this corresponds to the states `active` and `fastpath function call` in [`pg_stat_activity`](monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW))                    |
|`idle_in_transaction_time` `double precision`<br/><br/> Time spent idling while in a transaction in this database, in milliseconds (this corresponds to the states `idle in transaction` and `idle in transaction (aborted)` in [`pg_stat_activity`](monitoring-stats.html#MONITORING-PG-STAT-ACTIVITY-VIEW)) |
|                                                                                                             `sessions` `bigint`<br/><br/> Total number of sessions established to this database                                                                                                              |
|                                                                             `sessions_abandoned` `bigint`<br/><br/> Number of database sessions to this database that were terminated because connection to the client was lost                                                                              |
|                                                                                            `sessions_fatal` `bigint`<br/><br/> Number of database sessions to this database that were terminated by fatal errors                                                                                             |
|                                                                                       `sessions_killed` `bigint`<br/><br/> Number of database sessions to this database that were terminated by operator intervention                                                                                        |
|                                                                                                      `stats_reset` `timestamp with time zone`<br/><br/> Time at which these statistics were last reset                                                                                                       |

### 28.2.14. `pg_stat_database_conflicts`

[]()

 The `pg_stat_database_conflicts` view will contain one row per database, showing database-wide statistics about query cancels occurring due to conflicts with recovery on standby servers. This view will only contain information on standby servers, since conflicts do not occur on primary servers.

**Table 28.24. `pg_stat_database_conflicts` View**

|                                             Column Type<br/><br/> Description                                             |
|---------------------------------------------------------------------------------------------------------------------------|
|                                         `datid` `oid`<br/><br/> OID of a database                                         |
|                                     `datname` `name`<br/><br/> Name of this database                                      |
|`confl_tablespace` `bigint`<br/><br/> Number of queries in this database that have been canceled due to dropped tablespaces|
|      `confl_lock` `bigint`<br/><br/> Number of queries in this database that have been canceled due to lock timeouts      |
|    `confl_snapshot` `bigint`<br/><br/> Number of queries in this database that have been canceled due to old snapshots    |
|   `confl_bufferpin` `bigint`<br/><br/> Number of queries in this database that have been canceled due to pinned buffers   |
|      `confl_deadlock` `bigint`<br/><br/> Number of queries in this database that have been canceled due to deadlocks      |

### 28.2.15. `pg_stat_all_tables`

[]()

 The `pg_stat_all_tables` view will contain one row for each table in the current database (including TOAST tables), showing statistics about accesses to that specific table. The `pg_stat_user_tables` and `pg_stat_sys_tables` views contain the same information, but filtered to only show user and system tables respectively.

**Table 28.25. `pg_stat_all_tables` View**

|                                                 Column Type<br/><br/> Description                                                 |
|-----------------------------------------------------------------------------------------------------------------------------------|
|                                              `relid` `oid`<br/><br/> OID of a table                                               |
|                              `schemaname` `name`<br/><br/> Name of the schema that this table is in                               |
|                                           `relname` `name`<br/><br/> Name of this table                                           |
|                         `seq_scan` `bigint`<br/><br/> Number of sequential scans initiated on this table                          |
|                         `seq_tup_read` `bigint`<br/><br/> Number of live rows fetched by sequential scans                         |
|                            `idx_scan` `bigint`<br/><br/> Number of index scans initiated on this table                            |
|                           `idx_tup_fetch` `bigint`<br/><br/> Number of live rows fetched by index scans                           |
|                                      `n_tup_ins` `bigint`<br/><br/> Number of rows inserted                                       |
|                         `n_tup_upd` `bigint`<br/><br/> Number of rows updated (includes HOT updated rows)                         |
|                                       `n_tup_del` `bigint`<br/><br/> Number of rows deleted                                       |
|           `n_tup_hot_upd` `bigint`<br/><br/> Number of rows HOT updated (i.e., with no separate index update required)            |
|                                   `n_live_tup` `bigint`<br/><br/> Estimated number of live rows                                   |
|                                   `n_dead_tup` `bigint`<br/><br/> Estimated number of dead rows                                   |
|           `n_mod_since_analyze` `bigint`<br/><br/> Estimated number of rows modified since this table was last analyzed           |
|           `n_ins_since_vacuum` `bigint`<br/><br/> Estimated number of rows inserted since this table was last vacuumed            |
|`last_vacuum` `timestamp with time zone`<br/><br/> Last time at which this table was manually vacuumed (not counting `VACUUM FULL`)|
|    `last_autovacuum` `timestamp with time zone`<br/><br/> Last time at which this table was vacuumed by the autovacuum daemon     |
|              `last_analyze` `timestamp with time zone`<br/><br/> Last time at which this table was manually analyzed              |
|    `last_autoanalyze` `timestamp with time zone`<br/><br/> Last time at which this table was analyzed by the autovacuum daemon    |
|       `vacuum_count` `bigint`<br/><br/> Number of times this table has been manually vacuumed (not counting `VACUUM FULL`)        |
|            `autovacuum_count` `bigint`<br/><br/> Number of times this table has been vacuumed by the autovacuum daemon            |
|                     `analyze_count` `bigint`<br/><br/> Number of times this table has been manually analyzed                      |
|           `autoanalyze_count` `bigint`<br/><br/> Number of times this table has been analyzed by the autovacuum daemon            |

### 28.2.16. `pg_stat_all_indexes`

[]()

 The `pg_stat_all_indexes` view will contain one row for each index in the current database, showing statistics about accesses to that specific index. The `pg_stat_user_indexes` and `pg_stat_sys_indexes` views contain the same information, but filtered to only show user and system indexes respectively.

**Table 28.26. `pg_stat_all_indexes` View**

|                                     Column Type<br/><br/> Description                                     |
|-----------------------------------------------------------------------------------------------------------|
|                          `relid` `oid`<br/><br/> OID of the table for this index                          |
|                              `indexrelid` `oid`<br/><br/> OID of this index                               |
|                     `schemaname` `name`<br/><br/> Name of the schema this index is in                     |
|                        `relname` `name`<br/><br/> Name of the table for this index                        |
|                            `indexrelname` `name`<br/><br/> Name of this index                             |
|                `idx_scan` `bigint`<br/><br/> Number of index scans initiated on this index                |
|         `idx_tup_read` `bigint`<br/><br/> Number of index entries returned by scans on this index         |
|`idx_tup_fetch` `bigint`<br/><br/> Number of live table rows fetched by simple index scans using this index|

 Indexes can be used by simple index scans, “bitmap” index scans, and the optimizer. In a bitmap scan the output of several indexes can be combined via AND or OR rules, so it is difficult to associate individual heap row fetches with specific indexes when a bitmap scan is used. Therefore, a bitmap scan increments the `pg_stat_all_indexes`.`idx_tup_read` count(s) for the index(es) it uses, and it increments the `pg_stat_all_tables`.`idx_tup_fetch` count for the table, but it does not affect `pg_stat_all_indexes`.`idx_tup_fetch`. The optimizer also accesses indexes to check for supplied constants whose values are outside the recorded range of the optimizer statistics because the optimizer statistics might be stale.

### Note

 The `idx_tup_read` and `idx_tup_fetch` counts can be different even without any use of bitmap scans, because `idx_tup_read` counts index entries retrieved from the index while `idx_tup_fetch` counts live rows fetched from the table. The latter will be less if any dead or not-yet-committed rows are fetched using the index, or if any heap fetches are avoided by means of an index-only scan.

### 28.2.17. `pg_statio_all_tables`

[]()

 The `pg_statio_all_tables` view will contain one row for each table in the current database (including TOAST tables), showing statistics about I/O on that specific table. The `pg_statio_user_tables` and `pg_statio_sys_tables` views contain the same information, but filtered to only show user and system tables respectively.

**Table 28.27. `pg_statio_all_tables` View**

|                                      Column Type<br/><br/> Description                                      |
|-------------------------------------------------------------------------------------------------------------|
|                                   `relid` `oid`<br/><br/> OID of a table                                    |
|                   `schemaname` `name`<br/><br/> Name of the schema that this table is in                    |
|                                `relname` `name`<br/><br/> Name of this table                                |
|               `heap_blks_read` `bigint`<br/><br/> Number of disk blocks read from this table                |
|                   `heap_blks_hit` `bigint`<br/><br/> Number of buffer hits in this table                    |
|        `idx_blks_read` `bigint`<br/><br/> Number of disk blocks read from all indexes on this table         |
|            `idx_blks_hit` `bigint`<br/><br/> Number of buffer hits in all indexes on this table             |
|   `toast_blks_read` `bigint`<br/><br/> Number of disk blocks read from this table's TOAST table (if any)    |
|       `toast_blks_hit` `bigint`<br/><br/> Number of buffer hits in this table's TOAST table (if any)        |
|`tidx_blks_read` `bigint`<br/><br/> Number of disk blocks read from this table's TOAST table indexes (if any)|
|    `tidx_blks_hit` `bigint`<br/><br/> Number of buffer hits in this table's TOAST table indexes (if any)    |

### 28.2.18. `pg_statio_all_indexes`

[]()

 The `pg_statio_all_indexes` view will contain one row for each index in the current database, showing statistics about I/O on that specific index. The `pg_statio_user_indexes` and `pg_statio_sys_indexes` views contain the same information, but filtered to only show user and system indexes respectively.

**Table 28.28. `pg_statio_all_indexes` View**

|                      Column Type<br/><br/> Description                      |
|-----------------------------------------------------------------------------|
|           `relid` `oid`<br/><br/> OID of the table for this index           |
|               `indexrelid` `oid`<br/><br/> OID of this index                |
|      `schemaname` `name`<br/><br/> Name of the schema this index is in      |
|         `relname` `name`<br/><br/> Name of the table for this index         |
|             `indexrelname` `name`<br/><br/> Name of this index              |
|`idx_blks_read` `bigint`<br/><br/> Number of disk blocks read from this index|
|    `idx_blks_hit` `bigint`<br/><br/> Number of buffer hits in this index    |

### 28.2.19. `pg_statio_all_sequences`

[]()

 The `pg_statio_all_sequences` view will contain one row for each sequence in the current database, showing statistics about I/O on that specific sequence.

**Table 28.29. `pg_statio_all_sequences` View**

|                      Column Type<br/><br/> Description                     |
|----------------------------------------------------------------------------|
|                 `relid` `oid`<br/><br/> OID of a sequence                  |
|    `schemaname` `name`<br/><br/> Name of the schema this sequence is in    |
|              `relname` `name`<br/><br/> Name of this sequence              |
|`blks_read` `bigint`<br/><br/> Number of disk blocks read from this sequence|
|    `blks_hit` `bigint`<br/><br/> Number of buffer hits in this sequence    |

### 28.2.20. `pg_stat_user_functions`

[]()

 The `pg_stat_user_functions` view will contain one row for each tracked function, showing statistics about executions of that function. The [track\_functions](runtime-config-statistics.html#GUC-TRACK-FUNCTIONS) parameter controls exactly which functions are tracked.

**Table 28.30. `pg_stat_user_functions` View**

|                                                       Column Type<br/><br/> Description                                                      |
|----------------------------------------------------------------------------------------------------------------------------------------------|
|                                                  `funcid` `oid`<br/><br/> OID of a function                                                  |
|                                     `schemaname` `name`<br/><br/> Name of the schema this function is in                                     |
|                                              `funcname` `name`<br/><br/> Name of this function                                               |
|                                   `calls` `bigint`<br/><br/> Number of times this function has been called                                   |
|      `total_time` `double precision`<br/><br/> Total time spent in this function and all other functions called by it, in milliseconds       |
|`self_time` `double precision`<br/><br/> Total time spent in this function itself, not including other functions called by it, in milliseconds|

### 28.2.21. `pg_stat_slru`

[]()[]()

PostgreSQL accesses certain on-disk information via *SLRU* (simple least-recently-used) caches. The `pg_stat_slru` view will contain one row for each tracked SLRU cache, showing statistics about access to cached pages.

**Table 28.31. `pg_stat_slru` View**

|                                                                                       Column Type<br/><br/> Description                                                                                      |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                                                                                   `name` `text`<br/><br/> Name of the SLRU                                                                                   |
|                                                               `blks_zeroed` `bigint`<br/><br/> Number of blocks zeroed during initializations                                                                |
|`blks_hit` `bigint`<br/><br/> Number of times disk blocks were found already in the SLRU, so that a read was not necessary (this only includes hits in the SLRU, not the operating system's file system cache)|
|                                                                   `blks_read` `bigint`<br/><br/> Number of disk blocks read for this SLRU                                                                    |
|                                                                `blks_written` `bigint`<br/><br/> Number of disk blocks written for this SLRU                                                                 |
|                                                            `blks_exists` `bigint`<br/><br/> Number of blocks checked for existence for this SLRU                                                             |
|                                                                  `flushes` `bigint`<br/><br/> Number of flushes of dirty data for this SLRU                                                                  |
|                                                                       `truncates` `bigint`<br/><br/> Number of truncates for this SLRU                                                                       |
|                                                      `stats_reset` `timestamp with time zone`<br/><br/> Time at which these statistics were last reset                                                       |

### 28.2.22. Statistics Functions

 Other ways of looking at the statistics can be set up by writing queries that use the same underlying statistics access functions used by the standard views shown above. For details such as the functions' names, consult the definitions of the standard views. (For example, in psql you could issue `\d+ pg_stat_activity`.) The access functions for per-database statistics take a database OID as an argument to identify which database to report on. The per-table and per-index functions take a table or index OID. The functions for per-function statistics take a function OID. Note that only tables, indexes, and functions in the current database can be seen with these functions.

 Additional functions related to statistics collection are listed in [Table 28.32](monitoring-stats.html#MONITORING-STATS-FUNCS-TABLE).

**Table 28.32. Additional Statistics Functions**

|                                                                                                                                                                                                                                                                                                                                     Function<br/><br/> Description                                                                                                                                                                                                                                                                                                                                     |
|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                                                                                                                                                                                                                                                                                        `pg_backend_pid` () → `integer`<br/><br/> Returns the process ID of the server process attached to the current session.                                                                                                                                                                                                                                                                                         |
|                                                                                                                                                                                              []() `pg_stat_get_activity` ( `integer` ) → `setof record`<br/><br/> Returns a record of information about the backend with the specified process ID, or one record for each active backend in the system if `NULL` is specified. The fields returned are a subset of those in the `pg_stat_activity` view.                                                                                                                                                                                               |
|                                                                                                                                                                                                                                                                               []() `pg_stat_get_snapshot_timestamp` () → `timestamp with time zone`<br/><br/> Returns the timestamp of the current statistics snapshot.                                                                                                                                                                                                                                                                                |
|                                                                                                                                                                                                                                                                                                     []() `pg_stat_clear_snapshot` () → `void`<br/><br/> Discards the current statistics snapshot.                                                                                                                                                                                                                                                                                                      |
|                                                                                                                                                                                                                                []() `pg_stat_reset` () → `void`<br/><br/> Resets all statistics counters for the current database to zero.<br/><br/> This function is restricted to superusers by default, but other users can be granted EXECUTE to run the function.                                                                                                                                                                                                                                 |
|                                                                                          []() `pg_stat_reset_shared` ( `text` ) → `void`<br/><br/> Resets some cluster-wide statistics counters to zero, depending on the argument. The argument can be `bgwriter` to reset all the counters shown in the `pg_stat_bgwriter` view, `archiver` to reset all the counters shown in the `pg_stat_archiver` view or `wal` to reset all the counters shown in the `pg_stat_wal` view.<br/><br/> This function is restricted to superusers by default, but other users can be granted EXECUTE to run the function.                                                                                           |
|                                                                                                                                                                                                           []() `pg_stat_reset_single_table_counters` ( `oid` ) → `void`<br/><br/> Resets statistics for a single table or index in the current database to zero.<br/><br/> This function is restricted to superusers by default, but other users can be granted EXECUTE to run the function.                                                                                                                                                                                                           |
|                                                                                                                                                                                                            []() `pg_stat_reset_single_function_counters` ( `oid` ) → `void`<br/><br/> Resets statistics for a single function in the current database to zero.<br/><br/> This function is restricted to superusers by default, but other users can be granted EXECUTE to run the function.                                                                                                                                                                                                             |
|[]() `pg_stat_reset_slru` ( `text` ) → `void`<br/><br/> Resets statistics to zero for a single SLRU cache, or for all SLRUs in the cluster. If the argument is NULL, all counters shown in the `pg_stat_slru` view for all SLRU caches are reset. The argument can be one of `CommitTs`, `MultiXactMember`, `MultiXactOffset`, `Notify`, `Serial`, `Subtrans`, or `Xact` to reset the counters for only that entry. If the argument is `other` (or indeed, any unrecognized name), then the counters for all other SLRU caches, such as extension-defined caches, are reset.<br/><br/> This function is restricted to superusers by default, but other users can be granted EXECUTE to run the function.|
|                                                                                                                                                                             []() `pg_stat_reset_replication_slot` ( `text` ) → `void`<br/><br/> Resets statistics of the replication slot defined by the argument. If the argument is `NULL`, resets statistics for all the replication slots.<br/><br/> This function is restricted to superusers by default, but other users can be granted EXECUTE to run the function.                                                                                                                                                                             |

`pg_stat_get_activity`, the underlying function of the `pg_stat_activity` view, returns a set of records containing all the available information about each backend process. Sometimes it may be more convenient to obtain just a subset of this information. In such cases, an older set of per-backend statistics access functions can be used; these are shown in [Table 28.33](monitoring-stats.html#MONITORING-STATS-BACKEND-FUNCS-TABLE). These access functions use a backend ID number, which ranges from one to the number of currently active backends. The function `pg_stat_get_backend_idset` provides a convenient way to generate one row for each active backend for invoking these functions. For example, to show the PIDs and current queries of all backends:
```

李少辉-开发者's avatar
李少辉-开发者 已提交
903
选择pg_stat_get_backend_pid(s.backendid)作为pid,选择pg_stat_get_backend_activity(s.backendid)作为查询源(选择pg_stat_get_backend_idset()作为backendid)作为s;
K
KyleZhang 已提交
904

李少辉-开发者's avatar
李少辉-开发者 已提交
905
```
K
KyleZhang 已提交
906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921
**Table 28.33. Per-Backend Statistics Functions**

|                                                                                                                                  Function<br/><br/> Description                                                                                                                                 |
|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
|                                                                []() `pg_stat_get_backend_idset` () → `setof integer`<br/><br/> Returns the set of currently active backend ID numbers (from 1 to the number of active backends).                                                                |
|                                                                                   []() `pg_stat_get_backend_activity` ( `integer` ) → `text`<br/><br/> Returns the text of this backend's most recent query.                                                                                    |
|                                                                []() `pg_stat_get_backend_activity_start` ( `integer` ) → `timestamp with time zone`<br/><br/> Returns the time when the backend's most recent query was started.                                                                |
|                                                                             []() `pg_stat_get_backend_client_addr` ( `integer` ) → `inet`<br/><br/> Returns the IP address of the client connected to this backend.                                                                             |
|                                                                       []() `pg_stat_get_backend_client_port` ( `integer` ) → `integer`<br/><br/> Returns the TCP port number that the client is using for communication.                                                                        |
|                                                                                  []() `pg_stat_get_backend_dbid` ( `integer` ) → `oid`<br/><br/> Returns the OID of the database this backend is connected to.                                                                                  |
|                                                                                           []() `pg_stat_get_backend_pid` ( `integer` ) → `integer`<br/><br/> Returns the process ID of this backend.                                                                                            |
|                                                                              []() `pg_stat_get_backend_start` ( `integer` ) → `timestamp with time zone`<br/><br/> Returns the time when this process was started.                                                                              |
|                                                                                     []() `pg_stat_get_backend_userid` ( `integer` ) → `oid`<br/><br/> Returns the OID of the user logged into this backend.                                                                                     |
|                            []() `pg_stat_get_backend_wait_event_type` ( `integer` ) → `text`<br/><br/> Returns the wait event type name if this backend is currently waiting, otherwise NULL. See [Table 28.4](monitoring-stats.html#WAIT-EVENT-TABLE) for details.                             |
|[]() `pg_stat_get_backend_wait_event` ( `integer` ) → `text`<br/><br/> Returns the wait event name if this backend is currently waiting, otherwise NULL. See [Table 28.5](monitoring-stats.html#WAIT-EVENT-ACTIVITY-TABLE) through [Table 28.13](monitoring-stats.html#WAIT-EVENT-TIMEOUT-TABLE).|
|                                                                 []() `pg_stat_get_backend_xact_start` ( `integer` ) → `timestamp with time zone`<br/><br/> Returns the time when the backend's current transaction was started.                                                                 |
李少辉-开发者's avatar
李少辉-开发者 已提交
922
```