diff options
author | Peter Geoghegan | 2023-03-31 21:02:52 +0000 |
---|---|---|
committer | Peter Geoghegan | 2023-03-31 21:02:52 +0000 |
commit | df4f3ab51730a4cdddfead0b264d394ee4925723 (patch) | |
tree | 95b086f2a6e89b192555dd1bb1408f3225d45ae5 /contrib/pg_walinspect/pg_walinspect.c | |
parent | 6ee30209a6f161d0a267a33f090c70c579c87c00 (diff) |
Add show_data option to pg_get_wal_block_info.
Allow users to opt out of returning FPI data and block data from
pg_get_wal_block_info as an optimization. Testing has shown that this
can make function execution over twice as fast in some cases.
When pg_get_wal_block_info is called with "show_data := false", it
always returns NULL values for its block_data and block_fpi_data bytea
output parameters. Nothing else changes. In particular, the function
will still return the usual per-block summary of block data/FPI space
overhead. Use of "show_data := false" is therefore feasible with all
queries that don't specifically require these raw binary strings.
Follow-up to recent work in commit 122376f0. There still hasn't been a
stable release with the pg_get_wal_block_info function, so no bump in
the pg_walinspect extension version.
Per suggestion from Melanie Plageman.
Author: Peter Geoghegan <[email protected]>
Discussion: https://postgr.es/m/CAAKRu_bJvbcYBRj2cN6G2xV7B7-Ja+pjTO1nEnEhRR8OXYiABA@mail.gmail.com
Discussion: https://postgr.es/m/CAH2-Wzm9shOkEDM10_+qOZkRSQhKVxwBFiehH6EHWQQRd_rDPw@mail.gmail.com
Diffstat (limited to 'contrib/pg_walinspect/pg_walinspect.c')
-rw-r--r-- | contrib/pg_walinspect/pg_walinspect.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/contrib/pg_walinspect/pg_walinspect.c b/contrib/pg_walinspect/pg_walinspect.c index 1ff53c5abcc..e4dbf15e05d 100644 --- a/contrib/pg_walinspect/pg_walinspect.c +++ b/contrib/pg_walinspect/pg_walinspect.c @@ -59,7 +59,8 @@ static void GetWalStats(FunctionCallInfo fcinfo, XLogRecPtr start_lsn, XLogRecPtr end_lsn, bool stats_per_record); -static void GetWALBlockInfo(FunctionCallInfo fcinfo, XLogReaderState *record); +static void GetWALBlockInfo(FunctionCallInfo fcinfo, XLogReaderState *record, + bool show_data); /* * Return the LSN up to which the server has WAL. @@ -244,7 +245,8 @@ GetWALRecordInfo(XLogReaderState *record, Datum *values, * Keep this in sync with GetWALRecordInfo. */ static void -GetWALBlockInfo(FunctionCallInfo fcinfo, XLogReaderState *record) +GetWALBlockInfo(FunctionCallInfo fcinfo, XLogReaderState *record, + bool show_data) { #define PG_GET_WAL_BLOCK_INFO_COLS 20 int block_id; @@ -359,7 +361,7 @@ GetWALBlockInfo(FunctionCallInfo fcinfo, XLogReaderState *record) nulls[i++] = true; /* block_data output */ - if (blk->has_data) + if (blk->has_data && show_data) { bytea *block_data; @@ -372,7 +374,7 @@ GetWALBlockInfo(FunctionCallInfo fcinfo, XLogReaderState *record) nulls[i++] = true; /* block_fpi_data output */ - if (blk->has_image) + if (blk->has_image && show_data) { PGAlignedBlock buf; Page page; @@ -410,6 +412,7 @@ pg_get_wal_block_info(PG_FUNCTION_ARGS) { XLogRecPtr start_lsn = PG_GETARG_LSN(0); XLogRecPtr end_lsn = PG_GETARG_LSN(1); + bool show_data = PG_GETARG_BOOL(2); XLogReaderState *xlogreader; MemoryContext old_cxt; MemoryContext tmp_cxt; @@ -435,7 +438,7 @@ pg_get_wal_block_info(PG_FUNCTION_ARGS) /* Use the tmp context so we can clean up after each tuple is done */ old_cxt = MemoryContextSwitchTo(tmp_cxt); - GetWALBlockInfo(fcinfo, xlogreader); + GetWALBlockInfo(fcinfo, xlogreader, show_data); /* clean up and switch back */ MemoryContextSwitchTo(old_cxt); |