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 1vP3PL-0027q6-3B for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Nov 2025 18:41:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vP3PK-00D5ZN-1f for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Nov 2025 18:41:26 +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 1vP3PK-00D5ZE-0g for pgsql-hackers@lists.postgresql.org; Fri, 28 Nov 2025 18:41:26 +0000 Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vP3PI-001zQg-0B for pgsql-hackers@postgresql.org; Fri, 28 Nov 2025 18:41:25 +0000 Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-37b9728a353so27604431fa.0 for ; Fri, 28 Nov 2025 10:41:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764355283; x=1764960083; 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=8oWGOe9Vs4nrAUxnE3uPLTuDZ1g8qlkCRiLfKkruIYk=; b=iihdN7HcO8PL1QlFh1tcuUT4/HPD+QE0YGIDycmnyaqflBrZ+diRTSboeGmDitudyE f+GgxpfwuSYJcxP/CHvicxDnpy8D3OS8aX3NUk4Fe6mCAngAexH+aI4CPe5kA8ixsroq 4468CYOa2uDdBq23uj6u2onqktd77cSn4TxI7Fzn/j5z0EIu9K7DgHvk1hr7QiSf80qL Wfa3dhVA5YrK3kWAZzw5/fv6zE9SrTBhJKFOKMjsI4XGLwGhfqAPU/ea5xJIpptV2bgi 8mL/ZthVDJcNpO8hayqgx6sQYOtabS6cihypZkslZAQ++dAoUBzIrl+a2GIC8u/O//PV vMHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764355283; x=1764960083; 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=8oWGOe9Vs4nrAUxnE3uPLTuDZ1g8qlkCRiLfKkruIYk=; b=HspEUE2D5Ig2JdqrN92p9LJd+1+f70Za1ufJ2JQd10iYBmXXq4giSPghpIDr0Km75r eCGvOqSJBZi2taXcozwcT+1/B7O7mobx2N9VRRqXW3nyOTSYV72Ay41O0DRmu00YIqPe WAMYOrQ/4xcTVih6M+nMFrQTL82qj0xGpgvHnn4qiev+MmuUsdGonse+XJGTb8qW9zMl uh0NOP3GlfhG7lzNcwr3inkigx9ZT558mQJ0KaiDHlnJ7XcjDUwAHYZPznXP8LnrQY+1 LWuJE/m0IDPaDGnxtjjMU/Qb42J9bSDvvESe+jVDztk8bWGKpRWeo3BtD7OFoDTrxPik uwtw== X-Forwarded-Encrypted: i=1; AJvYcCW1PBLrbJjAThNNa5CMAC57Lv1bkb9omBJF/4zGZozQU+pWwVGAp5hABsZQKA0/fF6UJg2WTxqcE0e/kk2C@postgresql.org X-Gm-Message-State: AOJu0YxRI1UCJWk0rDtziFwwl27Gd538tbliZHasl0LMsLTwVggWqTVk C3z1PcdRVQR13fF3LSlSyCESaBHVyG+iXKKLDFO3rhWoXX7hNCPJ6PPOdE4ihe9Poq4houf3iLr fFZgVmr9XwPNWJgbSSBSmYizQY16lkDM= X-Gm-Gg: ASbGncvacox5jdQJ39r5WSqbyKWc3v4hWwxXr4bUX21h9ZiCUU+ucaYCBi8+X1xWW7T s2PwvFRBtKSfhn3+Xwtj1S6t5imTQb07OeFOIJ0Tal19f5PzdEw/kWLIxVEtpRolDLwzGTnnWGN UHIlW/qa0Vu4s6TaPEYmDpWGGOloWKy68sxowTYOHVGmJboLkL7trgP1KGiTwpQGU1K6P8BT7yp d4w3yC1Vo4oreQAcfy4HtVD/wIXI79+pt1v0mH8fEBra1F6bOGJrbTRFvVb7CHepHPCRA== X-Google-Smtp-Source: AGHT+IHsra9xPyiOLGKADEwI3Z2POmi6iueRdghHGZP8E1g+qaa3cMMgeLWcKAsRSibBEtTSpdPkf0Uv+Ptbosi0G50= X-Received: by 2002:a2e:98d5:0:b0:37b:99ec:9bfa with SMTP id 38308e7fff4ca-37cd93174e8mr56527481fa.45.1764355282939; Fri, 28 Nov 2025 10:41:22 -0800 (PST) MIME-Version: 1.0 References: <202505181556.3n6oiowvntyr@alvherre.pgsql> In-Reply-To: From: Mihail Nikalayeu Date: Fri, 28 Nov 2025 19:40:45 +0100 X-Gm-Features: AWmQ_bmmq0-5QoJ1mtjq-DETAGJrqQtxstbtwQHp9-0bZ5d9KSm9hP7JgrBH5Hg 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 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 Hello! On Fri, Nov 28, 2025 at 7:05=E2=80=AFPM Hannu Krosing w= rote: > 1. While the first pass of CIC is collecting the visible tuple for > index the logical decoding collector also collects any new tuples > added after the CIC start. > 2. When the first pass collection finishes, it also gets the indexes > collected so far by the logical decoding collectoir and adds them to > the first set before the sorting and creating the index. > > 3. once the initial index is created, the CIC just gets whatever else > was collected after 2. and adds these to the index It feels very similar to the approach with STIR (upper in that thread) - instead of doing the second scan - just collect all the new-coming TIDs in short-term-index-replacement access method. I think STIR lightweight AM (contains just TID) is a better option here than logical replication due several reason (Mathias already mentioned some of them). Anyway, it looks like things\threads became a little bit mixed-up, I'll try to structure it a little bit. For CIC/RC approach with resetting snapshot during heap scan - it is enough to achieve vacuum-friendly state in phase 1. For phase 2 (validation) - we need an additional thing - something to collect incoming tuples (STIR index AM is proposed). In that case we achieve vacuum-friendly for both phases + single heap scan. STIR at the same time may be used as just way to make CIC faster (single scan) - without any improvements related to VACUUM. You may check [0] for links. Another topic is REPACK CONCURRENTLY, which itself leaves in [1]. It is already based on LR. I was talking about a way to use the same tech (reset snapshot during the scan) for REPACK also, leveraging the already introduced LR decoding part. Mikhail. [0]: https://www.postgresql.org/message-id/flat/CADzfLwWkYi3r-CD_Bbkg-Mx0qx= MBzZZFQTL2ud7yHH2KDb1hdw%40mail.gmail.com [1]: https://www.postgresql.org/message-id/flat/202507262156.sb455angijk6%4= 0alvherre.pgsql