Re: Btree Index on PostgreSQL and Wiredtiger (MongoDB3.2) - Mailing list pgsql-hackers

From Greg Stark
Subject Re: Btree Index on PostgreSQL and Wiredtiger (MongoDB3.2)
Date
Msg-id CAM-w4HNkyT6g8UtM8aLT=HNx6P3njMY+Xd6ktbpcJkHDiBwu_w@mail.gmail.com
Whole thread Raw
In response to Re: Btree Index on PostgreSQL and Wiredtiger (MongoDB3.2)  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Responses Re: Btree Index on PostgreSQL and Wiredtiger (MongoDB3.2)  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
List pgsql-hackers
On Fri, Aug 12, 2016 at 8:13 PM, Andrew Gierth
<andrew@tao11.riddles.org.uk> wrote:
> No, because as the pages split, they fill more slowly (because there are
> now more pages). So on average in a large randomly filled index, pages
> spend more time nearer 50% full than 100% full. This is easy to
> demonstrate by creating a table with an indexed float8 column and adding
> batches of random() values to it, checking with pgstatindex at intervals -
> the average leaf density will rarely exceed 70%.
>
> However, worst case conditions can give lower leaf densities; obviously
> the worst case is if the data is loaded in an order and quantity that
> just happens to leave every leaf page recently split.


btree pages don't split 50/50 either. They split biased to assume the
greater side of the split will receive more inserts -- iirc 70/30. So
if they're loaded sequentially you should get a btree that's 70% full
but the worst case is in theory closer to 30% though I think the
insert order would have to be pretty perverse to be worse than 50%.

-- 
greg



pgsql-hackers by date:

Previous
From: Greg Stark
Date:
Subject: Re: Add hint for function named "is"
Next
From: Andrew Gierth
Date:
Subject: Re: No longer possible to query catalogs for index capabilities?