Re: SQL-level pg_datum_image_equal

From: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
To:
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, David Rowley <dgrowleyml(at)gmail(dot)com>, jian he <jian(dot)universality(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Heikki Linnakangas <hlinnaka(at)iki(dot)fi>
Subject: Re: SQL-level pg_datum_image_equal
Date: 2026-07-27 16:06:50
Message-ID: CAEze2WhrDiJ+vYUn_aTNx7MyUs+8x8ObUOJf=BiiUmGE0pgxzQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Here's version 3 of the patch, which is no more than a rebase.

Short recap: pg_datum_image_equal(any, any) -> bool allows
synchronization tools to reliably detect that colum values have not
changed in any way, for every type. Without this function, e.g.
numeric and jsonb columns wouldn't have a correct strict equality test
on the type itself (you'd have to cast to string and use a C-collated
equality against the string representation, which is relatively more
expensive). With this new function the UPDATE operation can use CASE
WHEN <equal> THEN old_val ELSE new_val END CASE; thus skipping
re-toasting the new value, reducing TOAST churn and also avoiding some
unneeded non-HOT updates in such synchronization workloads.

Kind regards,

Matthias van de Meent
Databricks (https://www.databricks.com)

p.s. The upthread issues with datum_image_*() have been resolved in 0d866282b8.

Attachment Content-Type Size
v3-0001-Add-SQL-level-datum-equality-tests.patch application/octet-stream 4.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Laurenz Albe 2026-07-27 16:24:28 Re: timestamp vs. timestamptz comparisons inconsistently ordered under DST
Previous Message Masahiko Sawada 2026-07-27 16:05:52 Re: Fix "unexpected logical decoding status change" error; from concurrent logical decoding activation