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 1vP5IC-003ciy-39 for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Nov 2025 20:42:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vP5IB-00DSG5-1q for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Nov 2025 20:42:11 +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 1vP5IB-00DSFx-0R for pgsql-hackers@lists.postgresql.org; Fri, 28 Nov 2025 20:42:11 +0000 Received: from mail-lf1-x12f.google.com ([2a00:1450:4864:20::12f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vP5I8-0020JX-2u for pgsql-hackers@postgresql.org; Fri, 28 Nov 2025 20:42:10 +0000 Received: by mail-lf1-x12f.google.com with SMTP id 2adb3069b0e04-5957c929a5eso3456927e87.1 for ; Fri, 28 Nov 2025 12:42:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764362527; x=1764967327; darn=postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=1umxm/tBgiWF6Xlzf+Y1eMtzaeIYbZ1EPIaN4AFDRgo=; b=nBqPfpv/cwuyXwBqi6dUnIT08aXbtqsb+38zTWPX0vjupCtWNhRpjmC+rHlWPfhgiE mcA5St8LTatnOq01HR4gXwjvbkaKIje91bxgvMZMfjNJ8Hyhg/OIILtXkIQvAt6/b+rh BqBrHXCS+BC1CrBjV1Nqq93XHtKr3xk5xm/xHFT9n8/YiJi8KngtT+Uupmwv6i3i6uyr 22KyBQJ4JnwqKivtpqh7trVm/y9D+YA0wmADePAYIV83oGMeCcdZ5CE3I4SrASzkJrep M4dTcPc9MpB/sAEXIt0wBXU54awvryJhLtpaN38k/MNG4vVJAv0K9DHxNFHXojlMgO4N sMgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764362527; x=1764967327; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=1umxm/tBgiWF6Xlzf+Y1eMtzaeIYbZ1EPIaN4AFDRgo=; b=aN+uWJVBILtqgE0z1VvDHOCxgstuirpYlaJuJocI6mrjTlxBp5r5oOY5PW9zhz1k1T NOBmcEKyXiOHVlEVlCVDY2jlC1hSJWw3CPtDIzN+0RuIb2kMEFimpqQC6BVOwAJm9ONC URRbB9onL3g0lZ1uUfaoTSwR3aTygwTdjcKpKdOhFOrXsJRYEyes1QBIrdHMq7LpckyD YvSo4zPgGBkP4fqRucG+cE8BwX15fxsiTb4sImbj7In5NXxx31ImtLVRv9JYjOwzMvu9 D/2M5WiXyT31nqQtsFfz5+BbtyMnq6eKS7evlkYZcTyTI4kKKSbwmv7hoicWQV9U2Plb E7lw== X-Forwarded-Encrypted: i=1; AJvYcCVjSvDiPObyxGnwYUOaXuom2N9TttrR1Z5g4I9RjeQL1ngnz5pnGiXUemKEAfeu/y7HdvK8mwVHwDWbLTpn@postgresql.org X-Gm-Message-State: AOJu0YwPTA6xdNZRvYgagXKB+PwkEfiYuR1vPcoa4fkGK/8s0b1anl6n q/b35fDo7BNoRlwuucZqQB4yNIpMGp1zFMCZ2IQ/XypCoJyIZWUZVSMOoAK1YCd64f01IAaBfid WXjLK8QHByvS26zZWFJsdgXROsM6W7AA= X-Gm-Gg: ASbGncuEcDRO09kU0eCPzLE5WS7KkNXz+VSsWV291Nd6R8ZdA1u0sONrwb2PONxk1qQ Gih11mgpKwo/CvmoQnSpn2PdCTW4fQvXyQxzxUmT7+ws7xPQxDO+jeH+f2gQGMpCm+eW2EZYfVz Pb0DOZWJ7lrsyWvSwUgm0z4FPMxYROzdCLlhpQSvTE9pm310/DrmpB0FqsM0WXodJkNkg7D3N2U rJq5uL2Y8fJLvOzuLlA8phfblFshrW1xbjgGHbL1hwkPvQVWFqHEzarQku95iQlbuWSx7trd0BB 21SjukNIa+SRVeOupm/3F5Od7HXJ1g== X-Google-Smtp-Source: AGHT+IEaACSNF3Li5Sm25jMukf+D6w5YxkUmSbiO5EvCeQJQuFNk+BuCrEZHtyRotMeyzBhSN8dg48gj0NaJw3oTGLo= X-Received: by 2002:a05:6512:1594:b0:594:2d53:545 with SMTP id 2adb3069b0e04-596b5297c04mr5754908e87.46.1764362526347; Fri, 28 Nov 2025 12:42:06 -0800 (PST) MIME-Version: 1.0 References: <202505181556.3n6oiowvntyr@alvherre.pgsql> In-Reply-To: From: Mihail Nikalayeu Date: Fri, 28 Nov 2025 21:41:15 +0100 X-Gm-Features: AWmQ_blA9nucYmtTOxtlMYZHTgbXfU8kZITWnfQhxabyhwVk5VkJ_cSry66r3cU Message-ID: Subject: Re: Revisiting {CREATE INDEX, REINDEX} CONCURRENTLY improvements To: Hannu Krosing Cc: Matthias van de Meent , Sergey Sargsyan , =?UTF-8?Q?=C3=81lvaro_Herrera?= , Andres Freund , Michael Paquier , PostgreSQL Hackers , Andrey Borodin , Melanie Plageman , Antonin Houska Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, Hannu! I think you pressed "Reply" instead of "Reply All" - so, I put it to the list (looks like nothing is secret here). Mostly it is because of my opinion at the end of the mail which I want to share with the list. On Fri, Nov 28, 2025 at 8:33=E2=80=AFPM Hannu Krosing w= rote: > If it is an *index AM* then this may not solve HOT chains issue (see > below), if we put it on top of *table AM* as some kind of pass-through > collector then likely yes, though you may still want to do final sort > in commit order to know which one is the latest version of updated > tuples which needs to go in the index. The latter is not strictly > needed, but would be a nice optimisation for oft-updated rows. It is AM which is added as an index (with the same columns/expressions/predicates) to the table before phase 1 starts. So, all new tuples are inserted into it. > And I would not collect just TID, but also the indexes value, as else > we end up accessing the table in some random order for getting the > value (and possibly do visibility checks) Just TIDs - it is ordered at validation phase (while merging with an main index) and read using AIO - pretty fast. > I am not sure where we decide that tuple is HOT-updatable, but I > suspect that it is before we call any index AMs, so STIR ios not > guaranteed to solve the issues with HOT chains. I am not sure what the HOT-chains issue is, but it actually works correctly already, including stress tests. It is even merged into one commercial fork of PG (I am not affiliated with it in any way). > (And yes, I have a patch in works to include old and new tids> as part > of logical decoding - they are "almost there", just not passed through > - which would help here too to easily keep just the last value) Yes, at least it is required for the REPACK case. But.... Antonin already has a prototype of patch to enable logical decoding for all kinds of tables in [0] (done in scope of REPACK). So, if we have such mechanics in place, it looks nice (and almost the same) for both CIC and REPACK: * in both cases we create temporary slot to collect incoming tuples * in both cases scan the table resetting snapshot every few pages to keep xmin horizon propagate * in both cases the process already collected part every few megabytes * just the logic of using collected tuples is different... So, yes, from terms of effectiveness STIR seems to be better, but such a common approach like LD looks tempting to have for both REPACK/CIC. On Fri, Nov 28, 2025 at 5:58=E2=80=AFPM Matthias van de Meent wrote: > -1: Requiring the logical decoding system just to reindex an index > without O(tablesize) lock time adds too much overhead, How big is the additional cost of maintaining logical decoding for a table? Could you please evolve a little bit? Best regards, Mikhail. [0]: https://www.postgresql.org/message-id/152010.1751307725%40localhost (v15-0007-Enable-logical-decoding-transiently-only-for-REPACK-.patch)