Re: Adding REPACK [concurrently] - Mailing list pgsql-hackers

From Noah Misch
Subject Re: Adding REPACK [concurrently]
Date
Msg-id 20260407011056.50.noahmisch@microsoft.com
Whole thread Raw
In response to Re: Adding REPACK [concurrently]  (Andres Freund <andres@anarazel.de>)
Responses Re: Adding REPACK [concurrently]
List 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.



pgsql-hackers by date:

Previous
From: Andres Freund
Date:
Subject: Re: Reduce timing overhead of EXPLAIN ANALYZE using rdtsc?
Next
From: Tomas Vondra
Date:
Subject: Re: EXPLAIN: showing ReadStream / prefetch stats