pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: David Rowley <drowley@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Add path column to pg_backend_memory_contexts view
Date: Thu, 25 Jul 2024 03:03:44 +0000
Message-ID: <E1sWolc-0015ev-Rn@gemulon.postgresql.org> (raw)

Add path column to pg_backend_memory_contexts view

"path" provides a reliable method of determining the parent/child
relationships between memory contexts.  Previously this could be done in
a non-reliable way by writing a recursive query and joining the "parent"
and "name" columns.  This wasn't reliable as the names were not unique,
which could result in joining to the wrong parent.

To make this reliable, "path" stores an array of numerical identifiers
starting with the identifier for TopLevelMemoryContext.  It contains an
element for each intermediate parent between that and the current context.

Incompatibility: Here we also adjust the "level" column to make it
1-based rather than 0-based.  A 1-based level provides a convenient way
to access elements in the "path" array. e.g. path[level] gives the
identifier for the current context.

Identifiers are not stable across multiple evaluations of the view.  In
an attempt to make these more stable for ad-hoc queries, the identifiers
are assigned breadth-first.  Contexts closer to TopLevelMemoryContext
are less likely to change between queries and during queries.

Author: Melih Mutlu <m.melihmutlu@gmail.com>
Discussion: https://postgr.es/m/CAGPVpCThLyOsj3e_gYEvLoHkr5w=tadDiN_=z2OwsK3VJppeBA@mail.gmail.com
Reviewed-by: Andres Freund, Stephen Frost, Atsushi Torikoshi,
Reviewed-by: Michael Paquier, Robert Haas, David Rowley

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/32d3ed8165f821f6994c95230a9a4b2ff0ce9f12

Modified Files
--------------
doc/src/sgml/system-views.sgml         |  40 +++++++-
src/backend/utils/adt/mcxtfuncs.c      | 180 +++++++++++++++++++++++++++------
src/include/catalog/catversion.h       |   2 +-
src/include/catalog/pg_proc.dat        |   6 +-
src/include/nodes/memnodes.h           |   4 +-
src/test/regress/expected/rules.out    |   3 +-
src/test/regress/expected/sysviews.out |  18 +++-
src/test/regress/sql/sysviews.sql      |  12 ++-
8 files changed, 225 insertions(+), 40 deletions(-)



Message-ID: <E1sWolc-0015ev-Rn@gemulon.postgresql.org>
Permalink:  ../E1sWolc-0015ev-Rn@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1sWolc-0015ev-Rn@gemulon.postgresql.org

 · 

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: pgsql-committers@postgresql.org
  Cc: drowley@postgresql.org, pgsql-committers@lists.postgresql.org
  Subject: Re: pgsql: Add path column to pg_backend_memory_contexts view
  In-Reply-To: <E1sWolc-0015ev-Rn@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox