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 1vzpLR-001M2i-19 for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Mar 2026 05:09:25 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1vzpLO-001fxR-1P for pgsql-hackers@arkaria.postgresql.org; Tue, 10 Mar 2026 05:09:22 +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 1vzpLO-001fxI-0L for pgsql-hackers@lists.postgresql.org; Tue, 10 Mar 2026 05:09:22 +0000 Received: from mail-ed1-x530.google.com ([2a00:1450:4864:20::530]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.98.2) (envelope-from ) id 1vzpLM-00000001OvR-1IBV for pgsql-hackers@postgresql.org; Tue, 10 Mar 2026 05:09:21 +0000 Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-662b42ca0daso1765258a12.3 for ; Mon, 09 Mar 2026 22:09:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1773119359; cv=none; d=google.com; s=arc-20240605; b=EkvERdTkqUDdxHBKuocjd4O5PUkaeTM8p0Lmf5Vd/WP4sKeDpHWydAhSDnKrimgWbR hUeTWCWSQE+C/Zy2PZHXjchNufm+PAgFQ+EagnGzUBj1ZSI5pa7VEGmeFFOFWu0KqvWb gaP5yUcZhJrpzHRO4EfuF0z8hJMNqcKX8rN9SBXtvbl7MQr3PYak6YNOve2h8u1lFYLX TkQ1O0Cia2VMcjGOoIK9amB6SUnuB9LQhLt5lXvTNnaIimieqN8m7JDXmjVar1tstGr9 zaolQJ4FD0uZxDDKtfH9WDfZI+rZKPeiRQ+y0A6/GR507Efkn4GSlHMVC9AMy415ulGT RJtw== 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=vFQdDcbCtvK2r1VBZ4duCJEKa3CDaClu5YZEP0E70EI=; fh=63sCsDZcCITfa1rSOxOmbP+JQUYUrbcuiAD8RZp0PIw=; b=GorflVS1IdRlHelwaRWzgM/y0wp63WNJ60WIeVCqqBhyoE8Bpc16WH6P17bft7ec3w Qi+LyzjQnERzuFCFR6tZ9lY0YbUe8s0x0ha9Clc5lUKgTe4ln6f88qa8H7thBVfX1i/O a4iZXENF3HXnZct7c6dd5fNFgWtzj8kAxJftPb1221BXSQHoWJUCWBAAvnZwzj61OvYN HcpRJ8QxxzOOGzpkoeDxE6tDrwAt0jfF3QCaqikquYN9ITnVvhz1ApKa/wivMzpiomZZ vlvTj9Fh80byMc2cz5vJZp2Ro9oKZxujBb1+kS/TwF09lNTMrgsKsrHvC7oesRvOO3hR a7Lw==; 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=1773119359; x=1773724159; 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=vFQdDcbCtvK2r1VBZ4duCJEKa3CDaClu5YZEP0E70EI=; b=FmSZ9Vj4JBlM/WVDKyEAm/+lZSpDH0ZxdhQPzXMDKbY9rs8SyrNAhwJxvBstUQQK5C hxv+wmLgkhw9mN/pcryfZbLmlQGPMfqqYGGiT/bCs8smB6b35bZoQzzyMdRbN/eYCg2A vuPlF1xkUdKfz6UctIM8cN/mNWdwX/0DQjN8XTTlxJ0kNZyCEz6vaGcJ8+uKYofTa2p3 ct1cSa1ab+iYLpmJMCAAWC2PZO5YfCCHrsvmNXodk1aMVvXAdATpLzNgLVatTIKwwyEW T4uhlkDRMcSZf5YPbNJgp4NQVPq3/ZhJVjSCd6oAGuPvjIFrNoo8vWwmLml+rv0qe/ZW tDdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773119359; x=1773724159; 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=vFQdDcbCtvK2r1VBZ4duCJEKa3CDaClu5YZEP0E70EI=; b=amZXAjHy5IziKpH87eGl7aKpHED2TghmLqhbcxLW1G1JZH+ua8AQiOqzvrDhfrd8qB bghOxM+aRJ27PGazmR7KZUkZ7FhcwQehG4Ci+s/RKoj60e6Fk6pNNO5+kPV54df16BRe QxUrDYiN8axplq2c7L0Zgal1OdgSIADajj/ZF+/GlTzDGGldYOnLtOf/7pi4RxdBLBve KLkk7GIgGp2wBRXMLNedxcI5AmLjW73Bdu8XFUfjWXUcmLkseOrEAa37f5qBZAjHwAm8 HoAzjsl+5G+ak3o8Z0a98sFSZH/85cDCoyG1CdXGlxxWZBIbnyNlexldTSXO1U0lwXJC ojfA== X-Forwarded-Encrypted: i=1; AJvYcCVywSDz+Or/F6NbKwBTnNM5WoK97fH+WI2G0yABUEew8XWLgsQiRs0j8ermcGCx8CsKDPJ8ajkJuhNARQgp@postgresql.org X-Gm-Message-State: AOJu0Yz1LOUIZwV4VP2d7UNVvZB4P7c5vDRbJ/YWfv6mBycaiDW7J+eF dC5+hef0tJR/sa9xC2YYRGtKKEHlijf5/dq6sCsriIebmDtoArgapTRLs4r4L8eUdxOVRLOmjVO ziSqf/7TF1eoIQoFXzi6p7vv1qYkXpDY= X-Gm-Gg: ATEYQzxRmLDNe8E3RYcuKm3lnt4+TJHAjWvbu7IQa7FIT/hrqsnJVYUkJI8He7xmX+x Qx7uMZ6jZWKXqeharENI9j7M1+AcVX20LjpAleyf0pWJlJ3gUefWLZXq/Bimgcfoc2OQUeWmMU9 BWiXCceCjGylEYYlqU4YIgwncS3X1XgAgyAisT+UZce7ptL8pL/A03afw6NuLLckILGzLsFPZYi odmCawi6qhTzfHuiWtUxSXUIFcHOra4iBqoBFZ9dH5AwINDu7viq/cFA05U48Tqgp1dPya4ZFcg BAlU3MKM X-Received: by 2002:a05:6402:399b:b0:662:d11e:e680 with SMTP id 4fb4d7f45d1cf-662d11ee964mr320604a12.32.1773119358746; Mon, 09 Mar 2026 22:09:18 -0700 (PDT) MIME-Version: 1.0 References: <11A59C0C-A8C8-4642-8493-292D5DF8311D@yandex-team.ru> In-Reply-To: From: Madhav Madhusoodanan Date: Tue, 10 Mar 2026 10:39:07 +0530 X-Gm-Features: AaiRm52AV12E_NoaL8ADgqHUO1O8VY6RB0hcUMrxYcPFOYzcmjaMNjy-a1DLeO8 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, Mar 6, 2026 at 2:15=E2=80=AFAM Madhav Madhusoodanan wrote: > > Some parts of the merge flow that I am coming up with are as follows > (assuming tuples from index page B are migrated rightwards into C): > > 1. Leaving B's tuples as it is even after merge, to remove the > possible risk of scans "skipping over" tuples. Essentially, the tuples > then would be "copied" into C. > 2. Marking pages B and C with flags similar to INCOMPLETE_SPLIT (say, > MERGE_SRC and MERGE_DEST respectively) before the actual merge > process, then marking the pages with another flag upon completion > (MERGE_COMPLETE) so that other processes can handle transient merge > states. > 3. For example, scans that reach page B post-merge (MERGE_SRC + > MERGE_COMPLETE) would be made to skip to the page to its right. > 4. Updating VACUUM to handle post-merge cleanup (to remove pages such as = B). > I was going through the source code to understand whether the aforementioned direction of changes would be reasonable. I was observing `BTPageOpaqueData.btpo_flags` [0] which is a uint16, but only 9 bits are used. Would using a couple bits of the same for this purpose be reasonable? Or are they being reserved for future functionality? Thanks! Madhav [0] https://github.com/postgres/postgres/blob/03facc1211b0ff1550f41bcd4da09= 329080c30f9/src/include/access/nbtree.h#L63