X-Original-To: pgsql-hackers-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id A9D939FA6B2 for ; Wed, 26 Jul 2006 11:26:51 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 75803-02 for ; Wed, 26 Jul 2006 11:26:41 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id E4AC19FA4E0 for ; Wed, 26 Jul 2006 11:26:11 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id k6QEQ1pM001594; Wed, 26 Jul 2006 10:26:01 -0400 (EDT) To: Mark Kirkwood cc: Josh Berkus , Gavin Sherry , Jie Zhang , pgsql-hackers@postgresql.org, Luke Lonergan Subject: Re: On-disk bitmap index patch In-reply-to: <44C6C8CB.9030802@paradise.net.nz> References: <28525.1153698215@sss.pgh.pa.us> <28750.1153700718@sss.pgh.pa.us> <44C6652C.1020203@agliodbs.com> <24309.1153860389@sss.pgh.pa.us> <44C6C8CB.9030802@paradise.net.nz> Comments: In-reply-to Mark Kirkwood message dated "Wed, 26 Jul 2006 13:43:39 +1200" Date: Wed, 26 Jul 2006 10:26:01 -0400 Message-ID: <1593.1153923961@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.043 tagged_above=0 required=5 tests=AWL, SPF_HELO_PASS, SPF_PASS X-Spam-Level: X-Archive-Number: 200607/1274 X-Sequence-Number: 87129 I wrote: >> ... A realistic assumption for the numbers you mention is >> that the bitmaps have 1-bits about 100 bits apart, which means you >> could get maybe 3-to-1 compression using the runlength scheme that's >> in there ... leaving the bitmap a factor of 20 bigger than the btree. I'm surprised no one caught me making this bogus computation. I realized this morning it's wrong: if there are 10000 distinct values then on the average the 1-bits would be about 10000 bits apart, not 100. At that rate there *is* substantial compression. The representation used in the bitmap patch isn't amazingly efficient for this (I wonder whether they oughtn't use 16-bit instead of 8-bit HRL_WORDs) but it still manages to get down to something like 11 bytes per 1-bit. Since each 1-bit corresponds to a btree entry, this means the bitmap does come out somewhat smaller than a btree (16 bytes per entry ignoring overhead) --- at least if overhead such as wasted space on a page doesn't kill it. Still, this isn't going to make the difference between fitting in RAM or not. For small numbers of distinct values, like less than 100, the bitmap representation looks more plausible. In that range you're down to a byte or two per entry and so there is (very roughly) a 10x storage savings over btree. I don't believe the 100x numbers that have been bandied around in this discussion, but 10x is plenty enough to be interesting. regards, tom lane