Re: How much clustered?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Carlos Henrique Reimer <carlosreimer(at)yahoo(dot)com(dot)br>, pgsql-general(at)postgresql(dot)org
Subject: Re: How much clustered?
Date: 2006-02-24 18:46:08
Message-ID: 200602241846.k1OIk8725454@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Tom Lane wrote:
> Carlos Henrique Reimer <carlosreimer(at)yahoo(dot)com(dot)br> writes:
> > I would like to know how much clustered is a table related to some index.... How can I discover?
>
> You could do
> select ctid from mytable order by indexcolumns
> and then do whatever sort of calculation strikes your fancy on the
> sequence of page numbers. (It's probably fair to ignore the row
> numbers, considering an index to be fully clustered if the page
> reference sequence is perfect.)

Currently we output the ctid as a string:

snprintf(buf, sizeof(buf), "(%u,%u)", blockNumber, offsetNumber);

Perhaps someday we should consider outputting that as an array or a
result set:

test=> select x from (select 1, 2) as x;
x
-------
(1,2)
(1 row)

--
Bruce Momjian http://candle.pha.pa.us
SRA OSS, Inc. http://www.sraoss.com

+ If your life is a hard drive, Christ can be your backup. +

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2006-02-24 19:40:00 Re: ltree + gist index performance degrades significantly over a night
Previous Message Scott Marlowe 2006-02-24 18:39:42 Re: Backup file extension