| From: | David Rowley <dgrowleyml(at)gmail(dot)com> | 
|---|---|
| To: | torikoshia <torikoshia(at)oss(dot)nttdata(dot)com> | 
| Cc: | pgsql-hackers(at)postgresql(dot)org | 
| Subject: | Re: Align memory context level numbering in pg_log_backend_memory_contexts() | 
| Date: | 2025-04-15 21:03:45 | 
| Message-ID: | CAApHDvpE6JS9F5kg+W4+p9TsiqFsPE+6XqEtD0P0HKNBoa9tYA@mail.gmail.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-hackers | 
On Wed, 16 Apr 2025 at 01:23, torikoshia <torikoshia(at)oss(dot)nttdata(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Alvaro Herrera | 2025-04-15 21:10:26 | Re: not null constraints, again | 
| Previous Message | David Rowley | 2025-04-15 20:49:46 | Re: Add estimated hit ratio to Memoize in EXPLAIN to explain cost adjustment |