Fix pgstatindex using for large indexes

From: Tatsuhito Kasahara <kasahara(dot)tatsuhito(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-patches(at)postgresql(dot)org
Cc: "kasahara(OSSC)" <kasahara(dot)tatsuhito(at)oss(dot)ntt(dot)co(dot)jp>
Subject: Fix pgstatindex using for large indexes
Date: 2008-02-21 13:45:55
Message-ID: 47BD8093.7060105@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches

Hi.

In pgstatindex.c and pgstattuple.sql, some variables are defined with
int type. So when we try to get informations about a large index by using
pgstatindex, we get strange value of size and density.
Because the values exceed int-max.
# Like following output. I used pgstatindex just after data load.
So "density" is should be nearly 90.

test=# SELECT * FROM pgstatindex('large_index');
-[ RECORD 1 ]------+------------
version | 2
tree_level | 4
index_size | -1349410816 ★
root_block_no | 119666
internal_pages | 28936
leaf_pages | 1379204
empty_pages | 0
deleted_pages | 0
avg_leaf_density | 60.33 ★
leaf_fragmentation | 0

I think that max_avail and free_space should be uint64.
And the output format for index_size should be "%lld" (INT64_FORMAT).

I made the patch and tryed it. (And it seemed OK.)

test=# SELECT * FROM pgstatindex('large_index');
-[ RECORD 1 ]------+------------
version | 2
tree_level | 4
index_size | 11535491072
root_block_no | 119666
internal_pages | 28936
leaf_pages | 1379204
empty_pages | 0
deleted_pages | 0
avg_leaf_density | 90.64
leaf_fragmentation | 0

I also fix *_pages variables just in case.
Please confirm this.

Best regards.

--
NTT OSS Center
Tatsuhito Kasahara

kasahara.tatsuhito _at_ oss.ntt.co.jp

Attachment Content-Type Size
pgstatindex.patch text/plain 4.8 KB

Responses

Browse pgsql-patches by date

  From Date Subject
Next Message Dave Page 2008-02-21 15:02:07 Fix for initdb failures on Vista
Previous Message Richard Huxton 2008-02-21 12:00:25 Re: ts_headline