public inbox for [email protected]
help / color / mirror / Atom feedFrom: Stephen Frost <[email protected]>
To: Andres Freund <[email protected]>
Cc: Melih Mutlu <[email protected]>
Cc: PostgreSQL Hackers <[email protected]>
Subject: Re: Parent/child context relation in pg_get_backend_memory_contexts()
Date: Thu, 19 Oct 2023 18:01:23 -0400
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <CAGPVpCThLyOsj3e_gYEvLoHkr5w=tadDiN_=z2OwsK3VJppeBA@mail.gmail.com>
<CAGPVpCRNGd4V6MsxOttDZG4Hbf-4c1rrQKL4CsLyhaSY4sNkjA@mail.gmail.com>
<[email protected]>
<[email protected]>
Greetings,
* Andres Freund ([email protected]) wrote:
> On 2023-10-18 15:53:30 -0400, Stephen Frost wrote:
> > > Here how pg_backend_memory_contexts would look like with this patch:
> > >
> > > postgres=# SELECT name, id, parent, parent_id, path
> > > FROM pg_backend_memory_contexts
> > > ORDER BY total_bytes DESC LIMIT 10;
> > > name | id | parent | parent_id | path
> > > -------------------------+-----+------------------+-----------+--------------
> > > CacheMemoryContext | 27 | TopMemoryContext | 0 | {0}
> > > Timezones | 124 | TopMemoryContext | 0 | {0}
> > > TopMemoryContext | 0 | | |
> > > MessageContext | 8 | TopMemoryContext | 0 | {0}
> > > WAL record construction | 118 | TopMemoryContext | 0 | {0}
> > > ExecutorState | 18 | PortalContext | 17 | {0,16,17}
> > > TupleSort main | 19 | ExecutorState | 18 | {0,16,17,18}
> > > TransactionAbortContext | 14 | TopMemoryContext | 0 | {0}
> > > smgr relation table | 10 | TopMemoryContext | 0 | {0}
> > > GUC hash table | 123 | GUCMemoryContext | 122 | {0,122}
> > > (10 rows)
> > >
> > > An example query to calculate the total_bytes including its children for a
> > > context (say CacheMemoryContext) would look like this:
> > >
> > > WITH contexts AS (
> > > SELECT * FROM pg_backend_memory_contexts
> > > )
> > > SELECT sum(total_bytes)
> > > FROM contexts
> > > WHERE ARRAY[(SELECT id FROM contexts WHERE name = 'CacheMemoryContext')] <@
> > > path;
> >
> > I wonder if we should perhaps just include
> > "total_bytes_including_children" as another column? Certainly seems
> > like a very useful thing that folks would like to see.
>
> The "issue" is where to stop - should we also add that for some of the other
> columns? They are a bit less important, but not that much.
I'm not sure the others really make sense to aggregate in this way as
free space isn't able to be moved between contexts. That said, if
someone wants it then I'm not against that. I'm actively in support of
adding an aggregated total though as that, at least to me, seems to be
very useful to have.
Thanks,
Stephen
Attachments:
[application/pgp-signature] signature.asc (833B, ../[email protected]/2-signature.asc)
download
view thread (19+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected], [email protected], [email protected]
Subject: Re: Parent/child context relation in pg_get_backend_memory_contexts()
In-Reply-To: <[email protected]>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox