Re: Parent/child context relation in pg_get_backend_memory_contexts()
Melih Mutlu <m.melihmutlu@gmail.com>
From: Melih Mutlu <m.melihmutlu@gmail.com>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>,
torikoshia <torikoshia@oss.nttdata.com>, Andres Freund <andres@anarazel.de>, Stephen Frost <sfrost@snowman.net>, PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-07-09T10:56:32Z
Lists: pgsql-hackers
Attachments
- v7-0002-Add-total_bytes_including_children-column.patch (application/octet-stream) patch v7-0002
- v7-0001-context_ids-column-in-pg_backend_memory_contexts.patch (application/octet-stream) patch v7-0001
Hi David, David Rowley <dgrowleyml@gmail.com>, 5 Tem 2024 Cum, 11:06 tarihinde şunu yazdı: > With the order you have it, that query could be expressed as: > > WITH c AS (SELECT * FROM pg_backend_memory_contexts) > SELECT c1.* > FROM c c1, c c2 > WHERE c2.name = 'CacheMemoryContext' > AND c1.path[c2.level + 1] = c2.path[c2.level + 1]; > > Whereas, with the way I had in mind, it would need to look like: > > WITH c AS (SELECT * FROM pg_backend_memory_contexts) > SELECT c1.* > FROM c c1, c c2 > WHERE c2.name = 'CacheMemoryContext' > AND c1.path[c1.level - c2.level + 1] = c2.path[1]; > > I kind of think the latter makes more sense, as if for some reason you > know the level and context ID of the context you're looking up, you > can do: > I liked the fact that a context would always be at the same position, level+1, in all context_ids arrays of its children. But what you described makes sense as well, so I changed the order. I also imagined "path" would be called "context_ids". I thought that > might better indicate what the column is without consulting the > documentation. > Done. > I think it might also be easier to document what context_ids is: > > "Array of transient identifiers to describe the memory context > hierarchy. The first array element contains the ID for the current > context and each subsequent ID is the parent of the previous element. > Note that these IDs are unstable between multiple invocations of the > view. See the example query below for advice on how to use this > column effectively." > Done. > There are also a couple of white space issues with the patch. If > you're in a branch with the patch applied directly onto master, then > "git diff master --check" should show where they are. > Done. Thanks, -- Melih Mutlu Microsoft
Commits
-
Add missing pointer dereference in pg_backend_memory_contexts view
- da87dc07f16e 18.0 landed
-
Add path column to pg_backend_memory_contexts view
- 32d3ed8165f8 18.0 landed
-
Allow memory contexts to have both fixed and variable ident strings.
- 442accc3fe0c 11.0 cited