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.98.2) (envelope-from ) id 1xOfPF-00000000Gfg-1jPY for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Nov 2026 18:08:19 +0000 Received: from localhost ([127.0.0.1]:46306 helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.98.2) (envelope-from ) id 1xOfPF-00000007pLG-33Ct for pgsql-hackers@arkaria.postgresql.org; Wed, 04 Nov 2026 18:08:17 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]:48110) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xOfPF-00000007pL8-19gb for pgsql-hackers@lists.postgresql.org; Wed, 04 Nov 2026 18:08:17 +0000 Received: from mail-4398.protonmail.ch ([185.70.43.98]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1xOfPC-00000000Ffq-1JVw for pgsql-hackers@lists.postgresql.org; Wed, 04 Nov 2026 18:08:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=burd.me; s=protonmail; t=1793815692; x=1794074892; bh=GJ3ulfKWJpzaJ7lTVbhI+vnWgBd1VDzZv+arjVZ6cTo=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=PqpPs7cqV4UAHNS8XCd4ivXlZHoTtYbrvXpSPIq1z3DdxPOgZTUip9NM6hhgpq+Wc yLL0k4nI4TUXJzpA6o3OGFOd2zUgLys3G+svvWnpQAspE2tLr2MeSvaEab4GSkHDGQ +OThI6vDzW8FdEhkAalTZ1RU0RYRMN4Ba1sMcI0cEGi33vePNO0rGznDaBY4A5p0Ib t/+iGzvHtq3bB6Wwk5qoTKYQ4jaln7gaq/sSa36tANvGRtp0WR1sZYdN9MWc9B+Tcy wtp8ytkRaSVAXqIxvQPiW6sXqijwv2VjtQdl2ZTm+5BZ0v5/mC+rSzRdSuCo12QcPH I2/MwWJWd41LA== Date: Wed, 04 Nov 2026 18:08:07 +0000 To: fengyao0087@gmail.com From: Greg Burd Cc: pgsql-hackers@lists.postgresql.org, pg@bowt.ie Subject: Re: nbtree: opt-in leaf key prefix compression Message-ID: In-Reply-To: References: Feedback-ID: 2668248:user:proton X-Pm-Message-ID: c7a70916b582bae354934b7079d1c5c80ad1a044 MIME-Version: 1.0 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, 30 Oct 2026 19:52:00 +0800, Yao Feng wrote: > Hi Greg, Hey Yao, I wanted to follow-up again on a suggestion you made. > Thanks for working on this, took a look at the v4 patch. >=20 > I think this is very worthwhile work. FWIW, a recent SIGMOD paper on > B-tree compression (https://dl.acm.org/doi/10.1145/3654972) noted that > while front-coding saves a lot of space for strings, decompression CPU co= st > tends to be the main bottleneck for queries on modern hardware. Looking a= t > the v4 benchmarks, they mostly cover index size and write throughput -- d= id > you have a chance to measure read-side performance (e.g. index scans, poi= nt > lookups)? >=20 > A few quick questions from having played with something similar a while > back: >=20 > 1. Skipping decompression when index tuples aren't returned: > Right now _bt_readpage() eagerly calls _bt_getitem() to decode every leaf > tuple. That's necessary when the scan actually needs to return the index > tuple (like IndexOnlyScan), but for operations that don't return tuples a= nd > only care about the heap TID -- such as a plain IndexScan, BitmapIndexSca= n, > or COUNT(*) -- could we skip decompression? > > 2. Multi-column indexes: > The patch requires column 0 to be a varlena. I'm curious if you considere= d > supporting subsequent columns (e.g. for something like `(tenant_id int, u= rl > text)`), or if keeping it strictly to the first column was just a natural > place to draw the line on complexity for now? This is a good idea and if I dismissed it earlier I apologize. But it will be tricky to do. Each column used to form a key may need a different key prefix, or maybe more than one can share a key prefix on a page. I'll have to think about this and do some research to find out how this has been approached by other databases in the past. > 3. Prefix boundaries within a page: > With one prefix per page, if a page spans two different domains (say, a > bunch of `http://example.com/1` , `.../2` followed = by > `http://sample.org/1` , `.../2`), the second group > only shares "http://". Just curious if you've considered this kind of cas= e? I have not, in that case you'd ideally like multiple prefixes for the same column. Then you have a different set of issues to manage, which prefix belongs to a tuple? I'll have to dig on this one too. > Curious to hear your thoughts. >=20 > --=20 > Yao Feng thanks for the ideas, -greg