Re: Generate pg_stat_get_xact*() functions with Macros - Mailing list pgsql-hackers

From Andres Freund
Subject Re: Generate pg_stat_get_xact*() functions with Macros
Date
Msg-id 20230105232140.ycxfh5d4lvashek2@awork3.anarazel.de
Whole thread Raw
In response to Re: Generate pg_stat_get_xact*() functions with Macros  (Corey Huinker <corey.huinker@gmail.com>)
Responses Re: Generate pg_stat_get_xact*() functions with Macros
List pgsql-hackers
Hi,

On 2023-01-05 15:19:54 -0500, Corey Huinker wrote:
> It does get me wondering, however, if we reordered the three typedefs to
> group like-typed registers together, we could make them an array with the
> names becoming defined constant index values (or keeping them via a union),
> then the typedefs effectively become:

I think that'd make it substantially enough harder to work with the
datastructures that I don't want to go there.


The "more fundamental" approach would be to switch to using a table-returning
function for accessing these stat values. When just accessing a single counter
or two, the current approach avoids the overhead of having to construct a
tuple. But after that the overhead of having to fetch the stats data (i.e. a
hash table lookup, potentially some locking) multiple times takes over.

Unfortunately there's currently no way to dynamically switch between those
behaviours.

Greetings,

Andres Freund



pgsql-hackers by date:

Previous
From: Alex Fan
Date:
Subject: Re: [PATCH] Enable using llvm jitlink as an alternative llvm jit linker of old Rtdyld.
Next
From: Peter Geoghegan
Date:
Subject: Re: BUG: Postgres 14 + vacuum_defer_cleanup_age + FOR UPDATE + UPDATE