Re: Adding a stored generated column without long-lived locks

From: Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Cc: Alberto Piai <alberto(dot)piai(at)gmail(dot)com>, Álvaro Herrera <alvherre(at)kurilemu(dot)de>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: Adding a stored generated column without long-lived locks
Date: 2026-10-02 16:58:26
Message-ID: CAEze2Wirgxfh7puw_9WTGyg6Aps1HPTHMAQ2TEJUjO0Tej4ZYQ@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, 2 Oct 2026 at 09:30, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at> wrote:
>
> You could simply require the constraint to be
>
> ROW(col)::record *= ROW(expression)::record
>
> That would also behave as desired for NULL values.
>
> True, it looks hacky, but as you said, it is a constraint created
> for this special purpose.

I don't think that's a good solution: Whilst it may work, it also
adds significant and potentially unnecessary overhead to the execution
of the CHECK constraint. The added complexity in the expression
itself also increases the chance of a user defining the constraint
incorrectly.

Kind regards,

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

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Alexandre Felipe 2026-10-02 17:01:59 Re: Throwing away unnecessary spin-locks
Previous Message ahmed 2026-10-02 16:55:00 Re: Use instr_time for pg_stat_database block read/write time counters