Re: How many levels a B-tree has?

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Cris <cris(at)dmcid(dot)net>, pgsql-general(at)postgresql(dot)org
Subject: Re: How many levels a B-tree has?
Date: 2003-05-15 00:48:12
Message-ID: 20030515004812.GA2353@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Wed, May 14, 2003 at 12:42:17PM -0400, Tom Lane wrote:
> "Cris" <cris(at)dmcid(dot)net> writes:
> > I need to know (if it possible) how many LEVELS a B-tree index
> > has (to know how many accesses to the disk it would do in a query).
>
> In CVS tip we keep track of that information in the index's metapage
> (page zero). But in so-far-released versions it's not explicitly
> tracked anywhere. You'd have to actually chase down the tree from the
> root to a leaf to count the levels.

Does this level count takes into consideration the fast root of the
tree? I think it doesn't.

If this is so, the number of disk accesses will be overestimated by
reading only the level count. One should traverse levels down from the
true root to the fast root and substract that from the level count.

--
Alvaro Herrera (<alvherre[a]dcc.uchile.cl>)
"El dia que dejes de cambiar dejaras de vivir"

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Matthew Nuzum 2003-05-15 00:49:45 Re: - what protocol for an Internet postgres
Previous Message Reece Hart 2003-05-15 00:07:57 table inheritance and foreign keys