Re: Align memory context level numbering in pg_log_backend_memory_contexts()
David Rowley <dgrowleyml@gmail.com>
From: David Rowley <dgrowleyml@gmail.com>
To: torikoshia <torikoshia@oss.nttdata.com>
Cc: pgsql-hackers@postgresql.org
Date: 2025-04-15T21:03:45Z
Lists: pgsql-hackers
On Wed, 16 Apr 2025 at 01:23, torikoshia <torikoshia@oss.nttdata.com> wrote: > =# select name, level from pg_backend_memory_contexts; > name | level > ----------------------------+------- > TopMemoryContext | 1 > =# select pg_log_backend_memory_contexts(pg_backend_pid()); > > LOG: level: 0; TopMemoryContext: ... > However, for the sake of consistency and to avoid potential confusion, > would it make sense to also start the levels from 1 in > pg_log_backend_memory_contexts() starting in v18? That's not a very nice inconsistency. As for which one is changed... Quite a bit of thought and discussion occurred before 32d3ed81 to try to make the "path" and "level" columns as easy to use as possible, and making "level" 1-based was done as a result of trying to make queries that sum up a context and its children as easy as possible. The example at the end of [1] would be a little more complex with 0-based levels as we'd have to use level+1 as the index. My vote is to make the levels 1-based in all locations where we output the context information. Does anyone else have views on this? David [1] https://www.postgresql.org/docs/devel/view-pg-backend-memory-contexts.html
Commits
-
doc: Fix memory context level in pg_log_backend_memory_contexts() example.
- 706cbed35103 18.0 landed
-
Make levels 1-based in pg_log_backend_memory_contexts()
- d9e03864b6b4 18.0 landed
-
Add path column to pg_backend_memory_contexts view
- 32d3ed8165f8 18.0 cited