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 1vP1nT-000kGa-0X for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Nov 2025 16:58:15 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vP1nQ-00CU4v-0Y for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Nov 2025 16:58:12 +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 1vP1nP-00CU4n-2c for pgsql-hackers@lists.postgresql.org; Fri, 28 Nov 2025 16:58:12 +0000 Received: from mail-lj1-x229.google.com ([2a00:1450:4864:20::229]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vP1nN-0021Lf-2d for pgsql-hackers@postgresql.org; Fri, 28 Nov 2025 16:58:11 +0000 Received: by mail-lj1-x229.google.com with SMTP id 38308e7fff4ca-37b9728a353so26584301fa.0 for ; Fri, 28 Nov 2025 08:58:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764349088; x=1764953888; 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=qu3NLWDw36LtDSDFKWUS5BMNeN2jTyHOqG1p5PphFn4=; b=WXwsUnCZhZvCEsJleM7eqAnEToc9cUnC3AP/o0TL0seFGwUwQ+OPjhCHyt51xKnfz4 n4vzXPxAcGTYT2oFFnXBPJKejDUNJ1vGrL1Jm8g7ouwHfA2Uh9kEim8UDiXFfzXkFhYn fF4NptVvU27tR6XQeVCNA/Nhww5UqUA6d21cjs5yjRQkXCMoD8jJSP8DQV24nBOMC8d7 Cb0puLw0ztl9dl6/klNAaqb6RbYrBw6wArK2U46vQuNrH+Dsx12+hT3RRjmhxqt39uuj qvX6kVhqZkPQ8S7GtFfBW0/yfiattfBzVfbBclufkjkzhctXhy59pAfvCAUIkibHAv8B L30w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764349088; x=1764953888; 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=qu3NLWDw36LtDSDFKWUS5BMNeN2jTyHOqG1p5PphFn4=; b=TjehkkS/o5LTg+Gdj0BBWh72jkDpyYfXX8vVYZdwgwk5blmCNKr8sGSLbzHHxIKec/ qz3NafWPkrBEgu9O/4R7WihW3XycgZtaQMXDsRhT3C3Em+CVB1DC5pbG7Jb0rZZbWT1r KPS6Sq3CRhz4OE/fKBuAGm7t52fK9bmrJ8q5mabefJu0gzE77nOjQRbNFoptQA2SCmiU ZZirLaXE52FlbdghAqFCeUVy+dUc6KzWdGNIwdyAaa5ULF5VxUVqg6QwW4qRf1BGhxER Q7yUh5furCIpgPp9u74nirAWizrNExDyskfOf5TIAvqXCzevQEVU2Rxj7+LbbOezhXnW 6A6w== X-Forwarded-Encrypted: i=1; AJvYcCUQUUDO19517SneRQgS8IXe9vBkPSoaSIk042HF9dW7JZQwrltDoSaiA42q7nMbLDZBXQ35OmSOIhI3Roay@postgresql.org X-Gm-Message-State: AOJu0YwG95nllB0xvCaIQOcSyKFyBlNyHhxmuyLvLDQvmPEfbBkAgtq9 tGBdsjEs2Vnb9jsNVnKIhB1n8uHkNtLFshR5L0IepZQIiW1YZvIQlL2qyCquMc3jBVutf1C9JJd ahAx6kqZHJdhBnCo/MAXAtEiG8v2r66w= X-Gm-Gg: ASbGncuH8Gl5QRTIbu95A1Z6UCSATuaQG11bsJ3sqxSCMiFkHQsNILIi732Ny8deV/s S+YyRhx/hJ/3DrhemMW6CS5rJMnya1RsmUt0v2ShcqBzs5HpLRkBtgVLfo2o46+y+sWxPNzG+/n d8JnWS3XSWu8pfQ+i218Os6uJc8A3yZ3nvdt8/dyImsomqjpxWJboNF2RC9SUDkVrhrNxwhOsgP phBLIPeA9YE0y4NIzKGU2Yg6RUT0PDnoo9ngZ2ZUAcuc0eyeRif73L2cH3a4tZKYa24nhngEwBi ir9Sj/Sm+EliXxNWIyKR161mEoEw3VCzl0FAgOupPDT2E0CERDaagGWSFERaUgpfQH8jDLX7cbf i0vI= X-Google-Smtp-Source: AGHT+IFez+9p61coloukzIUxklHqnejRJkdfldGgmlNbaFRZWMbI8d0nQk2VNvV770Gff39oCusfGeDfU+Uy2TEeQUU= X-Received: by 2002:a2e:9f0f:0:b0:37a:3260:c8c1 with SMTP id 38308e7fff4ca-37cd92b2f93mr57634921fa.30.1764349087524; Fri, 28 Nov 2025 08:58:07 -0800 (PST) MIME-Version: 1.0 References: <202505181556.3n6oiowvntyr@alvherre.pgsql> In-Reply-To: From: Matthias van de Meent Date: Fri, 28 Nov 2025 17:57:55 +0100 X-Gm-Features: AWmQ_bmLrkqnOC9HjQrifwLArvaqNUTnR1fYGzyuF_7RpX_iRp4YRuxn56QidFE Message-ID: Subject: Re: Revisiting {CREATE INDEX, REINDEX} CONCURRENTLY improvements To: Mihail Nikalayeu Cc: 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 On Fri, 28 Nov 2025 at 15:50, Mihail Nikalayeu wrote: > > Hello! > > On Thu, Nov 27, 2025 at 9:07=E2=80=AFPM Matthias van de Meent > wrote: > > While it might not break, and might not hold back other tables' > > visibility horizons, it'll still hold back pruning on the table we're > > acting on, and that's likely one which already had bloat issues if > > you're running RIC (or REPACK). > > Yes, a good point about REPACK, agreed. > > BTW, what is about using the same reset snapshot technique for REPACK als= o? > > I thought it is impossible, but what if we: > > * while reading the heap we "remember" our current page position into > shared memory > * preserve all xmin/max/cid into newly created repacked table (we need > it for MVCC-safe approach anyway) > * in logical decoding layer - we check TID of our tuple and looking at > "current page" we may correctly decide what to do with at apply phase: > > - if it in "non-yet read pages" - ignore (we will read it later) - but > signal scan to ensure it will reset snapshot before that page > (reset_before =3D min(reset_before, tid)) > - if it in "already read pages" - remember the apply operation (with > exact target xmin/xmax and resulting xmin/xmax) Yes, exactly - keep track of which snapshot was used for which part of the table, and all updates that add/remove tuples from the scanned range after that snapshot are considered inserts/deletes, similar to how it'd work if LR had a filter on `ctid BETWEEN '(0, 0)' AND '(end-of-snapshot-scan)'` which then gets updated every so often. I'm a bit worried, though, that LR may lose updates due to commit order differences between WAL and PGPROC. I don't know how that's handled in logical decoding, and can't find much literature about it in the repo either. Kind regards, Matthias van de Meent Databricks (https://www.databricks.com)