On Wed, 16 Apr 2025 at 01:23, torikoshia <torikos...@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


Reply via email to