Skip to content

Commit 2973b1c

Browse files
committed
Lower bounds related to pgstats kinds
This commit changes stats kinds to have the following bounds, making their handling in core cheaper by default: - PGSTAT_KIND_CUSTOM_MIN 128 -> 24 - PGSTAT_KIND_MAX 256 -> 32 The original numbers were rather high, and showed an impact on performance in pgstat_report_stat() for the case of simple queries with its early-exit path if there are no pending statistics to flush. This logic will be improved more in a follow-up commit to bring the performance of pgstat_report_stat() on par with v17 and older versions. Lowering the bounds is a change worth doing on its own, independently of the other improvement. These new numbers should be enough to leave some room for the following years for built-in and custom stats kinds, with stable ID numbers. At least that should be enough to start with this facility for extension developers. It can be always increased in the tree depending on the requirements wanted. Per discussion with Andres Freund and Bertrand Drouvot. Discussion: https://postgr.es/m/eb224uegsga2hgq7dfq3ps5cduhpqej7ir2hjxzzozjthrekx5@dysei6buqthe Backpatch-through: 18
1 parent 33f74b8 commit 2973b1c

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/include/utils/pgstat_kind.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
/* Range of IDs allowed, for built-in and custom kinds */
2020
#define PGSTAT_KIND_MIN 1 /* Minimum ID allowed */
21-
#define PGSTAT_KIND_MAX 256 /* Maximum ID allowed */
21+
#define PGSTAT_KIND_MAX 32 /* Maximum ID allowed */
2222

2323
/* use 0 for INVALID, to catch zero-initialized data */
2424
#define PGSTAT_KIND_INVALID 0
@@ -46,7 +46,7 @@
4646
/* Custom stats kinds */
4747

4848
/* Range of IDs allowed for custom stats kinds */
49-
#define PGSTAT_KIND_CUSTOM_MIN 128
49+
#define PGSTAT_KIND_CUSTOM_MIN 24
5050
#define PGSTAT_KIND_CUSTOM_MAX PGSTAT_KIND_MAX
5151
#define PGSTAT_KIND_CUSTOM_SIZE (PGSTAT_KIND_CUSTOM_MAX - PGSTAT_KIND_CUSTOM_MIN + 1)
5252

@@ -55,7 +55,7 @@
5555
* development and have not reserved their own unique kind ID yet. See:
5656
* https://wiki.postgresql.org/wiki/CustomCumulativeStats
5757
*/
58-
#define PGSTAT_KIND_EXPERIMENTAL 128
58+
#define PGSTAT_KIND_EXPERIMENTAL 24
5959

6060
static inline bool
6161
pgstat_is_kind_builtin(PgStat_Kind kind)

src/test/modules/injection_points/injection_stats.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static const PgStat_KindInfo injection_stats = {
5959
/*
6060
* Kind ID reserved for statistics of injection points.
6161
*/
62-
#define PGSTAT_KIND_INJECTION 129
62+
#define PGSTAT_KIND_INJECTION 25
6363

6464
/* Track if stats are loaded */
6565
static bool inj_stats_loaded = false;

src/test/modules/injection_points/injection_stats_fixed.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static const PgStat_KindInfo injection_stats_fixed = {
6464
/*
6565
* Kind ID reserved for statistics of injection points.
6666
*/
67-
#define PGSTAT_KIND_INJECTION_FIXED 130
67+
#define PGSTAT_KIND_INJECTION_FIXED 26
6868

6969
/* Track if fixed-numbered stats are loaded */
7070
static bool inj_fixed_loaded = false;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy