Re: Add pg_walinspect function with block info columns

From: Peter Geoghegan <pg(at)bowt(dot)ie>
To: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>, melanieplageman(at)gmail(dot)com, boekewurm+postgres(at)gmail(dot)com, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Add pg_walinspect function with block info columns
Date: 2023-03-29 19:47:55
Message-ID: CAH2-WzmSOFO1oHth+D5kY9i+eDtkwsqaoDHShPi48TVb98R-4g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Mar 27, 2023 at 7:40 PM Peter Geoghegan <pg(at)bowt(dot)ie> wrote:
> Attached revision v7 adjusts the column order. This is still WIP, but
> gives a good idea of the direction I'm going in.

A couple of small tweaks to this appear in the attached revision, v8.
Now it looks like this:

pg(at)regression:5432 [1294231]=# select * from
pg_get_wal_block_info('0/10E9D80' , '0/10E9DC0');
┌─[ RECORD 1 ]──────┬────────────────────────────────────┐
│ start_lsn │ 0/10E9D80 │
│ end_lsn │ 0/10E9DC0 │
│ prev_lsn │ 0/10E9860 │
│ blockid │ 0 │
│ reltablespace │ 1,663 │
│ reldatabase │ 1 │
│ relfilenode │ 2,690 │
│ relforknumber │ 0 │
│ relblocknumber │ 5 │
│ xid │ 117 │
│ resource_manager │ Btree │
│ record_type │ INSERT_LEAF │
│ record_length │ 64 │
│ main_data_length │ 2 │
│ block_data_length │ 16 │
│ block_fpi_length │ 0 │
│ block_fpi_info │ ∅ │
│ description │ off 14 │
│ block_data │ \x00005400020010001407000000000000 │
│ block_fpi_data │ ∅ │
└───────────────────┴────────────────────────────────────┘

This is similar to what I showed recently for v7. Just two changes:

* The parameter formerly called fpi_data is now called block_fpi_data,
to enforce the idea that it's block specific (and for consistency with
the related block_fpi_length param).

* There is now a new column, which makes the size of block_data
explicit: block_data_length

This made sense on consistency grounds, since we already had a
block_fpi_length. But it also seems quite useful. In this example, I
can immediately see that this INSERT_LEAF record needed 2 bytes for
the block offset number (indicating off 14), and 16 bytes of block
data for the IndexTuple data itself. There is a more recognizable
pattern to things, since the size of tuples for a given relation tends
to be somewhat homogenous. block_data_length also seems like it could
provide users with a handy way of filtering out definitely-irrelevant
block references.

--
Peter Geoghegan

Attachment Content-Type Size
v8-0001-Emit-WAL-record-info-via-pg_get_wal_block_info.patch application/octet-stream 20.5 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2023-03-29 20:00:45 Re: running logical replication as the subscription owner
Previous Message Daniel Gustafsson 2023-03-29 19:14:23 Re: TAP output format in pg_regress