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 1wMqHw-000O0s-1U for pgsql-hackers@arkaria.postgresql.org; Tue, 12 May 2026 16:48:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wMqHs-005EHI-26 for pgsql-hackers@arkaria.postgresql.org; Tue, 12 May 2026 16:48:52 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wMqHs-005EHA-16 for pgsql-hackers@lists.postgresql.org; Tue, 12 May 2026 16:48:52 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1wMqHp-00000000Fs4-3Xi7 for pgsql-hackers@postgresql.org; Tue, 12 May 2026 16:48:52 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-488b3f8fa2bso65160755e9.1 for ; Tue, 12 May 2026 09:48:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1778604529; x=1779209329; darn=postgresql.org; h=message-id:date:content-transfer-encoding:mime-version:comments :references:in-reply-to:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2CeIe8NUSaYDSguPS4Ih2RPhiBZHWKV5/pASDJdHLTo=; b=kVG4r9+w+IGTV9QphuighO7VK/h4gH1A/DBlq0gCxpTrUl5BF8r7ivQtqvFGAJwH87 oQGdY93uB07TMHjKn+PwqUSPxP/NW+jP62OK69sUnrVldtArTyzmp+nv5/6Qq9h2ol1H 8NcNWKCGQm7aL2CaeMuhw5iWux9xGc7LL86SbnSGZByhzf/crqlOHReN2NvbdWawJ1md fu1wG7kWXCd/d3TQ2i1XuG3urdx80bICzSWHNyU6Qa1S+U3aHMnM/Bu0GyKd6wpFC4LK ZI5HatTGpvjogtKxhb9o4BEjST46nbqEQ9zUhL/GechR6/msni1jyzhBfEiZZtDve6nO pkvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778604529; x=1779209329; h=message-id:date:content-transfer-encoding:mime-version:comments :references:in-reply-to:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2CeIe8NUSaYDSguPS4Ih2RPhiBZHWKV5/pASDJdHLTo=; b=moJnmclVWhHe8R+hZzZhavueKdIJvNQg9F223wYAeX3nc12uFDx7diktGApNRHgWOZ uVlXwJ+sbLy0G548OUXgmZ3ov2Kf7yqo9FdKaIZ6SCOphPvyJ/zLuLOkar1dWcWG+ttL B9GZI5228R/EjxKRyIcxNAbqlKNyg4VtKfD7iuN9q/DuDiIN0B1t9y0wpKK9f2FjwbC5 cejpTU7XDsab6/6dkQ3o5ikJVFUnbQ2nIznGYGpyMGAMpwC1DCyqWMzT2+mREQKThuat rU10yBgw53iIs10pxDcCjJF3xF7t2Waqp/UMAwQ/FuhFUzHamzUeD4jAdAB2BjEqRGPW 7WUg== X-Forwarded-Encrypted: i=1; AFNElJ8tynSo/jB3U7Iymf1kmd79imOQVFOUp5ahzotExigJuXH37QhAxYw7dZGJQ0hTM5WwodGPb5nhkut2Q+CX@postgresql.org X-Gm-Message-State: AOJu0Yzi5+Q/XQszwUUwtodGISRDmDH2DRwduvAAmI/cQTwTGtv2lpdb BbCF7ElmBh6BXN5qlBW+PVq/oCiuJMnl77YIK4wGtYC3W/o16gCZwzKBeZiqZ/QkDPQ= X-Gm-Gg: Acq92OEdhSnMqKJVcExfpksgyet/yiNbjTtIKwCvGSwpIN1IGQtVKrMziIa72nd2zEi wZhM/Mz70qbPwMDm2MRhHHV05A6Mk1cVRIo7Qa92z+dcZ/deCuuaC/JhyHHJwJwWXdZ0O5DA9/Y 6opF8jTgQefB12KRVVByG8yBj/7fwN+lT0wVmUPz3+qT5GAcd6LkURZ+46wc4gyr2ePwP/kxu1d lArKd1XwdZkNOFluSmCwSG+PGIygFabGggjsS7FH7qPJJT3OG0cbt0cDsqKo2bYgLifJv8iOl8n y/oYmgdOozNCaCCezFnJwtsRLUJx2Tnkc4kOetM+DMJME3YMqK+qilQ5dtLqpfcuRYuWj3bzfs/ UHjMahkMwwH5lPN7wqDC0YI/cNNUZmlDx+fL7ulPm7QG7z0NjeFq5TkYOq89bLL+IxFpLvsPcFq upgvcj1L6rI2c6GN0JOigRUZoeT6fNFZMNhW6b X-Received: by 2002:a05:600c:3f0a:b0:48a:5339:a46 with SMTP id 5b1f17b1804b1-48e8e208ec7mr73281575e9.9.1778604529270; Tue, 12 May 2026 09:48:49 -0700 (PDT) Received: from localhost (109-81-168-142.rct.o2.cz. [109.81.168.142]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48fc8d27d31sm15054905e9.8.2026.05.12.09.48.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 May 2026 09:48:48 -0700 (PDT) From: Antonin Houska To: alvherre@kurilemu.de cc: Chao Li , Kirill Reshke , PostgreSQL-development Subject: Re: Fix REPACK with WITHOUT OVERLAPS replica identity indexes In-reply-to: References: Comments: In-reply-to =?us-ascii?Q?=3D=3Futf-8=3FQ=3F=3DC3=3D81lvaro=3F=3D?= Herrera message dated "Mon, 11 May 2026 18:21:17 +0200." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 12 May 2026 18:48:48 +0200 Message-ID: <70401.1778604528@localhost> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk =C3=81lvaro Herrera wrote: > On 2026-May-11, Chao Li wrote: >=20 > > > On May 10, 2026, at 06:38, =C3=81lvaro Herrera = wrote: >=20 > > > I think it would be a good idea to make identity_key_equal() not defo= rm > > > all attributes, but instead only up to the last one it needs for the = key > > > comparisons. > >=20 > > That=E2=80=99s true. Please see v3. >=20 > Thanks. I did one further small change, namely to determine these last > attnums just once per run rather than once per tuple. Pushed now. I appreciate that REPACK can handle more cases now! However, I found a prob= lem (or at least a question) when rebasing the improvements for the next release(s). (It's related to splitting the table scan into multiple block ranges and use one snapshot per range, details are not too important here, ) Assertion failure in the new code made me think if other than B-tree indexes should be allowed in the USING INDEX clause of REPACK. AFAICS, only B-tree indexes (and some special ones that don't appear in the core) provide ordering information - see get_relation_info(): /* * Fetch the ordering information for the index, if any. */ if (info->relam =3D=3D BTREE_AM_OID) { ... info->sortopfamily =3D info->opfamily; ... } else if (amroutine->amcanorder) { /* * Otherwise, identify the corresponding btree opfamilies * by trying to map this index's "<" operators into btree. * Since "<" uniquely defines the behavior of a sort * order, this is a sufficient test. ... } else { ... info->sortopfamily =3D NULL; ... } Therefore, index scan shouldn't be possible for GIST index - see build_index_paths(): index_is_ordered =3D (index->sortopfamily !=3D NULL); So I'm not sure if clustering makes sense here. What makes me confused is t= hat GIST has IndexAmRoutine.amclusterable=3Dtrue. As it has amcanorder=3Dfalse = at the same time, I suspect it might be just a thinko. However, if we simply set amclusterable to false, it can break upgrade to PG 19 for users who already "clustered" some table by a GIST index (for mysterious reasons). (BTW, do we need the amclusterable field at all?) REPACK currently rejects explicit sort if non-B-tree index is specified (due to lack of ordering information), but it still scans the index rather than the heap - see copy_table_data() and heapam_relation_copy_for_cluster(). Does this seem worth fixing now? Or maybe at least worth some comments (unl= ess I'm completely wrong)? --=20 Antonin Houska Web: https://www.cybertec-postgresql.com