Re: Parent/child context relation in pg_get_backend_memory_contexts()

From: Melih Mutlu <m(dot)melihmutlu(at)gmail(dot)com>
To: torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>
Cc: Andres Freund <andres(at)anarazel(dot)de>, Stephen Frost <sfrost(at)snowman(dot)net>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: Parent/child context relation in pg_get_backend_memory_contexts()
Date: 2024-01-16 09:41:22
Message-ID: CAGPVpCSvNDXy1vDTjgGVCOCAndQ6iB_LVyjb1GNATEqdx8zLHw@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

Thanks for reviewing.

torikoshia <torikoshia(at)oss(dot)nttdata(dot)com>, 10 Oca 2024 Çar, 09:37 tarihinde
şunu yazdı:

> > + <row>
> > + <entry role="catalog_table_entry"><para
> > role="column_definition">
> > + <structfield>context_id</structfield> <type>int4</type>
> > + </para>
> > + <para>
> > + Current context id. Note that the context id is a temporary id
> > and may
> > + change in each invocation
> > + </para></entry>
> > + </row>
> > +
> > + <row>
> > + <entry role="catalog_table_entry"><para
> > role="column_definition">
> > + <structfield>path</structfield> <type>int4[]</type>
> > + </para>
> > + <para>
> > + Path to reach the current context from TopMemoryContext.
> > Context ids in
> > + this list represents all parents of the current context. This
> > can be
> > + used to build the parent and child relation
> > + </para></entry>
> > + </row>
> > +
> > + <row>
> > + <entry role="catalog_table_entry"><para
> > role="column_definition">
> > + <structfield>total_bytes_including_children</structfield>
> > <type>int8</type>
> > + </para>
> > + <para>
> > + Total bytes allocated for this memory context including its
> > children
> > + </para></entry>
> > + </row>
>
> These columns are currently added to the bottom of the table, but it may
> be better to put semantically similar items close together and change
> the insertion position with reference to other system views. For
> example,
>
> - In pg_group and pg_user, 'id' is placed on the line following 'name',
> so 'context_id' be placed on the line following 'name'
> - 'path' is similar with 'parent' and 'level' in that these are
> information about the location of the context, 'path' be placed to next
> to them.
>
> If we do this, orders of columns in the system view should be the same,
> I think.
>

I've done what you suggested. Also moved "total_bytes_including_children"
right after "total_bytes".

14dd0f27d have introduced new macro foreach_int.
> It seems to be able to make the code a bit simpler and the commit log
> says this macro is primarily intended for use in new code. For example:
>

Makes sense. Done.

Thanks,
--
Melih Mutlu
Microsoft

Attachment Content-Type Size
v5-0001-Adding-id-parent_id-into-pg_backend_memory_contex.patch application/octet-stream 12.2 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2024-01-16 10:00:29 Re: remaining sql/json patches
Previous Message shveta malik 2024-01-16 09:40:31 Re: Synchronizing slots from primary to standby