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 1vweIy-003ohb-04 for pgsql-hackers@arkaria.postgresql.org; Sun, 01 Mar 2026 10:45:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vweIw-00Cme8-2N for pgsql-hackers@arkaria.postgresql.org; Sun, 01 Mar 2026 10:45:42 +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 1vweIw-00Cmdw-1F for pgsql-hackers@lists.postgresql.org; Sun, 01 Mar 2026 10:45:42 +0000 Received: from mail-ed1-x52f.google.com ([2a00:1450:4864:20::52f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vweIt-00000001rMu-1xhd for pgsql-hackers@postgresql.org; Sun, 01 Mar 2026 10:45:42 +0000 Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-65fa79f5c98so5910366a12.1 for ; Sun, 01 Mar 2026 02:45:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1772361934; cv=none; d=google.com; s=arc-20240605; b=foDDaYnd9+rpVBwVfhlOl/8uYBF0GiWCRbjFrfHNAilUCsKt+1kw6kiR6yuMn3rRwT IEHDtNDXZsiwCY4dSjA9w9DBdt272ULKP31/pHcTN/c6Lr2YzinXviAPfmYlyFBLU1uZ HMlUSnMZh5QHd50Ir/Ya1T82JXTn4gzRkYdNpSHvGl327cja2Nojx1e5+2EsiKlgEidi QJ7yR4aGbCXYqMn+cIeN0XW69skFKBSVF2aCR93impXsz6f8IKqhcWZvGJbZmxaMYEg9 7+MIJ4KVVNWIQl44PM3xuOKsSX4BK4WM5vmSZqpRbfVbNO/gZP4gsiFBFXrVdV5SorAC eRog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=D/+97MkDlRAQWSL3fbbo1bSX0XEkULUifLzC7ryiZRU=; fh=FJDGD/aJnptfqcSeRvNLxp1N9xqtC+8u4vuOQx02RiQ=; b=CyJBm/9qH0OD+aocQomzUAQ1Sm1gclb5vqo8aeV+lBFq0MfnmFwpUKm8r315qA1GoY E6B4WupdPOXRGfs++sW3FD/kVQSbzTrNJMQsQPu1vcGM5SjQtaP5MzGZ9kbtoHVyY0/9 gdCbLNjBJAdBy8RRZOcFc9ExLJQJ/6qaHC8t69Vv69+kUwOuZ58aC/xHiFM5B3NsEwU9 +mkz8Qf2Nq8SHfNnjGQoQrJ8zDaSCX1R36/3W5kLAP7AdWdDpyM70gEcWzMTvtT+j9Zx +iMQCx2pZaT4vgxTkq0MfEMJteePtWH/K8F4+o9hP3Ua2S2RREOp6cS0sTLuM4oMKF/5 s/sg==; darn=postgresql.org ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772361934; x=1772966734; 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=D/+97MkDlRAQWSL3fbbo1bSX0XEkULUifLzC7ryiZRU=; b=Aaqx3ChcSAiQruAF6mNmvzCR1AV194ckOy2N7MnrLwlTLU9klojKfjAYOPkKF/TsD3 zrjo3mU+vmuMKpFzk4wb3xSoqGSH115XiQSKciaQjtYt6hE+4ygQJr0ttOnz5Cn/DIBi TEG/gE2DNwtEcgYJMEZYehc2aoClcD9JWkXcfzPRiXbeLkANemjJw49FkGGfWjypzyGg 8V2JVMYAJa0eggFEGG34DzhHKZmYKaKqilNQmn+UQ/H3RgeQgf/xoa/BOto7/6hbf1pI XLyLxAhop7xr7VMBFJsJVeJxdqkQO0SKsx5D8t/XS2jxmsjcfno0yL2tA6rV7Zob5R6b K41g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772361934; x=1772966734; 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=D/+97MkDlRAQWSL3fbbo1bSX0XEkULUifLzC7ryiZRU=; b=QC9EEE0Jxjze9ngEK7H6WpsLbv5g6ePsd16KUy82AfjBzRFpoe9Yxg3+uq5lYaCWaf LTQ2aEiXtikjYt4zkaO9HG/6+Aas15gcRfY/+Tc5ItAych0Fi3rA6heV7vFbyH9xI1Nb VVMY+oxZoE7VQHrVhk6+GfdpgNJ82N7HDEaNfW5MM15ahneBtQm2v1PhirsxmyVEijph em7BhNHn9giSdbPI73zNbVA0sz/RL0lXu72ra67WdE3jWKZXAzDJUhlYTd7pInAxNtvB ZBU8vdmvGow4HBt6kA9CZdg0GYKPI6eEA1FbIhO9jWEwUL5TxzIjfhOQTimkoh6WQrFG DiuQ== X-Forwarded-Encrypted: i=1; AJvYcCUNivvHoV7ztexFEedSbVJ9+QVYO7tIXLMQNtVCK8Vwmo0QrEncit1+3Pgb65yEB9hL9UMJ5yUgp0s3CRjh@postgresql.org X-Gm-Message-State: AOJu0YyZ0Xq6RoVuWJuVlVChNnG+5qNvwcQoEfdR6B9LD0Nb9o7Ph3XW tAJBbIgrmAf+OCJgF3NjEuSKwflIh4AzzpnDoM8cZ0StdWFg/XavJJg9V9seTwrB7qnqpWsJQFR +MQxTXnEV3i4I2wc8d01FsYcNgTMzdHE= X-Gm-Gg: ATEYQzxLwaUGbwXlHie80IgooC4jNC124FhOy4yQ2l1jZuj2/B+XMLUPD3gmLbgMAsr GSGtpx6yPjtwcUHArCXHJL/xYVTs7BdkzgVQ7Y+5jKRJtrkx3I9Iqwzc+6hp8sqVBfsRSYXz3NO /0e3Vfu36jzaHsODgUs281MXnp3qS3wbsnMtH96K4EB+9GRzKZjpP42B83fLwAEO5EWNmwATw26 46N4zyHJA2ljZe/dis25i91gqQuQixecBMqHe+3+WpUY4Ho1Adei/Mf3xDW74MnF8mmuk8mVudo 55cX2fwwJJgS3v3lK4GuyUbWmwgBAZehtcHQZkOvFjju9m8P X-Received: by 2002:a05:6402:510a:b0:659:31af:b9af with SMTP id 4fb4d7f45d1cf-65fe2b4fbe1mr5140894a12.0.1772361933951; Sun, 01 Mar 2026 02:45:33 -0800 (PST) MIME-Version: 1.0 References: <11A59C0C-A8C8-4642-8493-292D5DF8311D@yandex-team.ru> In-Reply-To: From: Madhav Madhusoodanan Date: Sun, 1 Mar 2026 16:15:22 +0530 X-Gm-Features: AaiRm52bOTpycKmEz0bL9qMMmVDhildu5gfdvun9KN5jLd82h4wEqz-FLf7Ooi4 Message-ID: Subject: Re: [WiP] B-tree page merge during vacuum to reduce index bloat To: Matthias van de Meent Cc: Kirk Wolak , Andrey Borodin , pgsql-hackers , Nikolay Samokhvalov 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, Feb 27, 2026 at 5:37=E2=80=AFPM Matthias van de Meent wrote: > > That is one part of the picture (the merging part), but it's missing a > lot of details: > - How do concurrent workloads (index scans, backwards index scans, > index insertions) detect and recover from concurrent merges when they > step through pages? > - Do you have a theory or proof of correctness for the above? > - Can this scheme be implemented without adding significant overhead > to current workloads that don't benefit significantly from the new > feature? > > One example for a problem with the given flow: where (and how) do you > update the sibling pointers in pages A (to N from B) and D (to N from > C)? > You haven't explicitly locked pages A and D by the time you get to > step 4, even though locking pages is critical to guarantee correct and > safe operations. Simply locking them in step 4 isn't sufficient, as > another process may have locked page A in preparation for a split, > which would then be waiting to get a lock on page B. If you've already > locked page B before locking page A, you'll have a deadlock. > > Additionally, how does this work when you find out in step 3 that your > pages B and C each are linked to from a different parent page? You'd > have to update both parent pages, but that would also require locking > more than just the one parent page per level that currently gets > locked during page deletion. Ohh I see, I haven't included the dynamics of such flows too. I might have to think this through. Thank you for pointing it out! Just to understand what we can control (and to help internalize the constraints so that I can think through a strategy): to handle transient merge states, are we intending to update core? Or is the bloat reduction functionality intended to be abstracted into an extension? I'm coming up with ways that might potentially update index amcheck and the like. Thanks in advance! Madhav