mirror of
https://github.com/postgres/postgres.git
synced 2025-07-14 08:21:07 +03:00
Speedup pgstat_report_activity by moving mb-aware truncation to read side.
Previously multi-byte aware truncation was done on every pgstat_report_activity() call - proving to be a bottleneck for workloads with long query strings that execute quickly. Instead move the truncation to the read side, which commonly is executed far less frequently. That's possible because all server encodings allow to determine the length of a multi-byte string from the first byte. Rename PgBackendStatus.st_activity to st_activity_raw so existing extension users of the field break - their code has to be adjusted to use pgstat_clip_activity(). Author: Andres Freund Tested-By: Khuntal Ghosh Reviewed-By: Robert Haas, Tom Lane Discussion: https://postgr.es/m/20170912071948.pa7igbpkkkviecpz@alap3.anarazel.de
This commit is contained in:
@ -1003,8 +1003,14 @@ typedef struct PgBackendStatus
|
||||
/* application name; MUST be null-terminated */
|
||||
char *st_appname;
|
||||
|
||||
/* current command string; MUST be null-terminated */
|
||||
char *st_activity;
|
||||
/*
|
||||
* Current command string; MUST be null-terminated. Note that this string
|
||||
* possibly is truncated in the middle of a multi-byte character. As
|
||||
* activity strings are stored more frequently than read, that allows to
|
||||
* move the cost of correct truncation to the display side. Use
|
||||
* pgstat_clip_activity() to truncate correctly.
|
||||
*/
|
||||
char *st_activity_raw;
|
||||
|
||||
/*
|
||||
* Command progress reporting. Any command which wishes can advertise
|
||||
@ -1193,6 +1199,8 @@ extern PgStat_BackendFunctionEntry *find_funcstat_entry(Oid func_id);
|
||||
|
||||
extern void pgstat_initstats(Relation rel);
|
||||
|
||||
extern char *pgstat_clip_activity(const char *activity);
|
||||
|
||||
/* ----------
|
||||
* pgstat_report_wait_start() -
|
||||
*
|
||||
|
Reference in New Issue
Block a user