Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w9uy9-001t80-2M for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Apr 2026 01:11:05 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1w9uy6-00DB33-1V for pgsql-hackers@arkaria.postgresql.org; Tue, 07 Apr 2026 01:11:02 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1w9uy5-00DB2v-35 for pgsql-hackers@lists.postgresql.org; Tue, 07 Apr 2026 01:11:02 +0000 Received: from mail-dy1-x132a.google.com ([2607:f8b0:4864:20::132a]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1w9uy4-00000000wjS-09JI for pgsql-hackers@lists.postgresql.org; Tue, 07 Apr 2026 01:11:01 +0000 Received: by mail-dy1-x132a.google.com with SMTP id 5a478bee46e88-2c54c68db4dso8941169eec.0 for ; Mon, 06 Apr 2026 18:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1775524259; x=1776129059; darn=lists.postgresql.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=fIMkLvrsyuSdEmjqYH+WxFgK5unnPUzvE0KT+W8M3u0=; b=CRsUa/DoFAGSs1n5wpG7B077Ynr4gtjwxUiQ7lKgPr7GP3nC3pUg3rgN6sKlTAqecw 57mRNPxmKz11vyWI4ExO/LUCjr2BGiHQbow8miHvB+eDxow6Xe2sxoE9gL45dPsiiD0U 9IckYUjP88u96VaWbCE3rM/Jr8tdkxYOVUDi0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775524259; x=1776129059; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=fIMkLvrsyuSdEmjqYH+WxFgK5unnPUzvE0KT+W8M3u0=; b=spo9Gn0vZ0wWX1Pt0q2Wr3dm6IhqP7GJUigkZeeQo32jgnVkKqa9XUnzi6YLWfBIkD /b1yUYD4eycFWryY0WhhR9u7TGbHe3W9OMIVSdqsTnDhDOVgnZcAiydY6z9A5qKFiVrE zYsjWi50GARzj+zNt7ByaAaYaHYIKAx0vVOUiViaAUhvrL2ivHHqIeuWtbHMmin6G1R8 SW/cQVMluI+IBdkpOarby4Yy9KzOw3gVvCzay+8iIBv4z0FskE1lIBDzfGONrCDcger/ tmk7w/woIvO5ZjVZbIlt1oLo0R+UO/GOPptPvQVz45WJklKVzjPLEBgYQ8QGjwkIwlE6 tCkg== X-Forwarded-Encrypted: i=1; AJvYcCWQ3+nNYTEDCVgXRcY47HwphCrm+xfx0rCYAoyCwYL7GJdUF0RHWLXvjIw7MAzffOzoecqcL3CrHu5zjTEx@lists.postgresql.org X-Gm-Message-State: AOJu0Yw/jB+3ZL39mgK+9VdYd1OIUBzkujO5eyFmX/RUC2bGSjRyndrl 0kMd/IdbAzZKHhtQfNCWEplnTUsWQwgV10pybqZR/1Q4ruc6H4ZUp84ieMzFWIpM+g== X-Gm-Gg: AeBDieuflBwukipNnx18L7xyP6ZmPLJpxYySM/g4d/Yy+7F1YuJgnZq2ZXJK3bHgD8T /goNtlr1gpjgMW7Hj5B2/RnYZj+7EKLT/mymyh8/Pg7mNdJ847gFyAAjWJZLrP5ZY9/OioF0vAb RwL6iJPGALA7JldIXGgnm7krg7C58f3/bPinWwVhEr67LIgPT/CBTb8k7Skr5b6r84GvvbHlVNy WMzb7hij6lBnoHN65Dh9opzgDuLOpkh+jemTGcu0SXhNmi0x0ZWnbFMJfeOB+epHMj+vRULbIml Mx95I3DgO20LQCHsZZHrCiPL33afLokOZZd1TKPurAy8rD6h0Mw79DTRBDzMOD3ID+HS/XAjx55 BQke3GaiT+XIly38HvHPOpV3R1Y4yFA6emFfqTTYiw0/EDiviS3Gdt4abJ2lEcCd00Ld/3xKN99 JZtT6JCgW/VYNpebyvqU30uddPnj1deSkycg3zeQhtNJlTOaMmjMMLJrE= X-Received: by 2002:a05:7300:ec07:b0:2c4:ec89:bd3 with SMTP id 5a478bee46e88-2cbfc55b4efmr6930032eec.24.1775524259194; Mon, 06 Apr 2026 18:10:59 -0700 (PDT) Received: from microsoft.com (c-73-15-160-255.hsd1.ca.comcast.net. [73.15.160.255]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-2cba5df5c24sm12746984eec.27.2026.04.06.18.10.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Apr 2026 18:10:58 -0700 (PDT) Date: Mon, 6 Apr 2026 18:10:56 -0700 From: Noah Misch To: Andres Freund Cc: Alvaro Herrera , vignesh C , Antonin Houska , Srinath Reddy Sadipiralla , Amit Kapila , Mihail Nikalayeu , Matthias van de Meent , Pg Hackers , Robert Treat Subject: Re: Adding REPACK [concurrently] Message-ID: <20260407011056.50.noahmisch@microsoft.com> References: <202604060918.qw5ms7cbr2hz@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.3.0 (2026-01-25) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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.