Re: pg_stat_bgwriter.buffers_backend is pretty meaningless (and more?)
Justin Pryzby <pryzby@telsasoft.com>
On Wed, Dec 01, 2021 at 05:00:14PM -0500, Melanie Plageman wrote: > > Also: > > src/include/miscadmin.h:#define BACKEND_NUM_TYPES (B_LOGGER + 1) > > > > I think it's wrong to say NUM_TYPES = B_LOGGER + 1 (which would suggest using > > lessthan-or-equal instead of lessthan as you are). > > > > Since the valid backend types start at 1 , the "count" of backend types is > > currently B_LOGGER (13) - not 14. I think you should remove the "+1" here. > > Then NROWS (if it continued to exist at all) wouldn't need to subtract one. > > I think what I currently have is technically correct because I start at > 1 when I am using it as a loop condition. I do waste a spot in the > arrays I allocate with BACKEND_NUM_TYPES size. > > I was hesitant to make the value of BACKEND_NUM_TYPES == B_LOGGER > because it seems kind of weird to have it have the same value as the > B_LOGGER enum. I don't mean to say that the code is misbehaving - I mean "num_x" means "the number of x's" - how many there are. Since the first, valid backend type is 1, and they're numbered consecutively and without duplicates, then "the number of backend types" is the same as the value of the last one (B_LOGGER). It's confusing if there's a macro called BACKEND_NUM_TYPES which is greater than the number of backend types. Most loops say for (int i=0; i<NUM; ++i) If it's 1-based, they say for (int i=1; i<=NUM; ++i) You have two different loops like: + for (int i = 0; i < BACKEND_NUM_TYPES - 1 ; i++) + for (int backend_type = 1; backend_type < BACKEND_NUM_TYPES; backend_type++) Both of these iterate over the correct number of backend types, but they both *look* wrong, which isn't desirable. -- Justin
Commits
-
Stabilize pg_stat_io writes test
- ef719e7b32fc 16.0 landed
-
Fix flakey pg_stat_io test
- 1be0fdb9de55 16.0 landed
-
Suppress more compiler warnings in new pgstats code.
- b1b86820d84e 16.0 landed
-
Suppress compiler warnings in new pgstats code.
- 728560db7d86 16.0 landed
-
Add tests for pg_stat_io
- 10a082bf7215 16.0 landed
-
Create regress_tblspc in test_setup
- 9c83bbcf7ef6 16.0 landed
-
Add pg_stat_io view, providing more detailed IO statistics
- a9c70b46dbe1 16.0 landed
-
pgstat: Track more detailed relation IO statistics
- f30d62c2fc60 16.0 landed
-
pgstat: Infrastructure for more detailed IO statistics
- 28e626bde00e 16.0 landed
-
doc: Fix some issues in logical replication section
- 4f74f5641d53 16.0 cited
-
Manual cleanup and pgindent of pgstat and bufmgr related code
- 250c8ee07ede 16.0 landed
-
Have the planner consider Incremental Sort for DISTINCT
- 3c6fc58209f2 16.0 cited
-
Use actual backend IDs in pg_stat_get_backend_idset() and friends.
- d7e39d72ca1c 16.0 cited
-
Remove redundant call to pgstat_report_wal()
- 1bdd54e662d5 16.0 landed
-
Add BackendType for standalone backends
- 0c679464a837 16.0 landed
-
Initialize backend status reporting during bootstrap.
- 3b34645678d1 15.0 landed