Query related to Logical Replication using test_decoding and unchanged-toast-datum

Started by Kiran K Vover 1 year ago2 messagesgeneral
Jump to latest
#1Kiran K V
kirankv.1982@gmail.com

Hi,

I am currently using PostgreSQL version 16 and the test_decoding plugin to
perform logical replication (using replication slots). I have a simple
table with integer column and JSON column. When a non-JSON column is
updated, the value "unchanged-toast-datum" for the JSON column is obtained.
This shows that the value recorded in a TOAST table for a JSON column value
has not changed and is as expected. could you please tell me whether
PostgreSQL will truly log these values to WAL or not ? If not, what will be
entered into WAL for the JSON column if it remains unchanged?

Please let me know. Thank you very much.

Regards,
Kiran

#2David G. Johnston
david.g.johnston@gmail.com
In reply to: Kiran K V (#1)
Re: Query related to Logical Replication using test_decoding and unchanged-toast-datum

On Mon, Jan 6, 2025 at 7:21 AM Kiran K V <kirankv.1982@gmail.com> wrote:

could you please tell me whether PostgreSQL will truly log these values to
WAL or not ? If not, what will be entered into WAL for the JSON column if
it remains unchanged?

Not quite sure what you are looking for but:

https://www.postgresql.org/docs/current/storage-toast.html#STORAGE-TOAST-ONDISK

"A pointer datum representing an out-of-line on-disk TOASTed value
therefore needs to store the OID of the TOAST table in which to look and
the OID of the specific value (its chunk_id). For convenience, pointer
datums also store the logical datum size (original uncompressed data
length), physical stored size (different if compression was applied), and
the compression method used, if any. Allowing for the varlena header bytes,
the total size of an on-disk TOAST pointer datum is therefore 18 bytes
regardless of the actual size of the represented value."

So the WAL of the main table data will contain 18bytes of data for that
column. If the toast data really hasn't changed during the period in
question the WAL will not contain any data for the toast relation since no
changes to it were made.

David J.