Re: Adding REPACK [concurrently]

From: Noah Misch <noah(at)leadboat(dot)com>
To: Andres Freund <andres(at)anarazel(dot)de>
Cc: Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, vignesh C <vignesh21(at)gmail(dot)com>, Antonin Houska <ah(at)cybertec(dot)at>, Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, Mihail Nikalayeu <mihailnikalayeu(at)gmail(dot)com>, Matthias van de Meent <boekewurm+postgres(at)gmail(dot)com>, Pg Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Robert Treat <rob(at)xzilla(dot)net>
Subject: Re: Adding REPACK [concurrently]
Date: 2026-04-07 01:10:56
Message-ID: 20260407011056.50.noahmisch@microsoft.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Apr 06, 2026 at 05:11:30PM -0400, Andres Freund wrote:
> heap_insert()
> ->CacheInvalidateHeapTuple()
> ->CacheInvalidateHeapTupleCommon()
> ->AssertCouldGetRelation()
> not being cheap and running a *lot*.
>
> Admittedly it's way worse if you build with -O0, which I tend to do to make
> debugging easier.
>
> In that config, the assert single-handled increases the time for a repack by
> 35% or so.
>
>
> Noah, is there any reason we need to do the AssertCouldGetRelation() before
> the !IsCatalogRelation(relation)? Given that the goal is to make
> RelationGetRelid() safe, it doesn't seem there is?

By running AssertCouldGetRelation() during every INSERT statement, this
detects cases that would be unsafe when the target of the INSERT happens to be
a system catalog. Little of our INSERT/UPDATE coverage targets a system
catalog. Hence, the current position is better for detection.

I wonder if this got slower in v19. In v14-v18, the assert's cost is
proportional to the number of held lwlocks, often 0 or 1. In v19, it's
proportional to PrivateRefCountHash cardinality.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tomas Vondra 2026-04-07 01:14:49 Re: EXPLAIN: showing ReadStream / prefetch stats
Previous Message Andres Freund 2026-04-07 00:40:00 Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc?