Re: Index size - Mailing list pgsql-general

From Tatsuo Ishii
Subject Re: Index size
Date
Msg-id 20050302.110230.26537022.t-ishii@sra.co.jp
Whole thread Raw
In response to Re: Index size  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: Index size
List pgsql-general
> > Interesting. Right after CREATE INDEX for a int4 column using pgbench
> > -s 10(1,000,000 tuples), I got 2184 leaf pages. From my caliculation
> > the number of leaf pages is expected to 1965, which is 100% full case
> > assumption of course. So 1965/2184 = 0.8997 = 90% is actually used?
>
> Shoulda read the code rather than going by memory ;-).  What nbtsort.c
> actually says is
>
>  * It is not wise to pack the pages entirely full, since then *any*
>  * insertion would cause a split (and not only of the leaf page; the need
>  * for a split would cascade right up the tree).  The steady-state load
>  * factor for btrees is usually estimated at 70%.  We choose to pack leaf
>  * pages to 90% and upper pages to 70%.  This gives us reasonable density
>  * (there aren't many upper pages if the keys are reasonable-size) without
>  * incurring a lot of cascading splits during early insertions.
>
> and indeed the code seems to do that:
>
>     /* set "full" threshold based on level.  See notes at head of file. */
>     if (level > 0)
>         state->btps_full = (PageGetPageSize(state->btps_page) * 3) / 10;
>     else
>         state->btps_full = PageGetPageSize(state->btps_page) / 10;
>

Thanks for the explanation.

So it seems Ioannis' number was not taken immediately after a CREATE
INDEX operation?
--
Tatsuo Ishii

pgsql-general by date:

Previous
From: Tom Lane
Date:
Subject: Re: Index size
Next
From: Tom Lane
Date:
Subject: Re: Index size