Re: pgstattuple extension for indexes

From: Martijn van Oosterhout <kleptog(at)svana(dot)org>
To: ITAGAKI Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
Cc: Satoshi Nagayasu <nagayasus(at)nttdata(dot)co(dot)jp>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: pgstattuple extension for indexes
Date: 2006-08-17 12:23:48
Message-ID: 20060817122348.GB31061@svana.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

On Thu, Aug 17, 2006 at 12:55:28PM +0900, ITAGAKI Takahiro wrote:
> I think this condition should be regarded as full-fragmented,
> but pgstatindex reports that the leaf_fragmentation is 50%.
>
> Presently, fragmentation factor is computed as the code below:
>
> if (opaque->btpo_next != P_NONE && opaque->btpo_next < blkno)
> stat->fragments++;
>
> But the method has the above problem. So I suggest to use whether
> the right link points to the next adjacent page or not.
>
> if (opaque->btpo_next != P_NONE && opaque->btpo_next != blkno + 1)
> stat->fragments++;
>
> Do you think which method is better? Or do you have other ideas?

If we do it your way, then every index will probably get a
fragmentation of nearly 100%. That's not very useful. I don't agree
that your example is fully fragmented, since on the first read the OS
will read the next four (or more) blocks so all the others are
zero-cost.

A more useful definition of fragmentation would be: if you're scanning
forward through an index, how often do you have to jump backwards
again. The current calculation seems to get that fairly right...

Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> From each according to his ability. To each according to his ability to litigate.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2006-08-17 12:52:42 Re: Enum proposal / design
Previous Message Greg Stark 2006-08-17 11:47:15 Re: CREATE INDEX ... ONLINE

Browse pgsql-patches by date

  From Date Subject
Next Message Tom Lane 2006-08-17 12:54:00 Re: [PATCHES] WIP: bitmap indexes
Previous Message Greg Stark 2006-08-17 11:47:15 Re: CREATE INDEX ... ONLINE