Received: from maia.hub.org (maia-3.hub.org [200.46.204.243]) by mail.postgresql.org (Postfix) with ESMTP id D3936133655C for ; Thu, 16 Dec 2010 15:27:19 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.243]) (amavisd-maia, port 10024) with ESMTP id 62495-05 for ; Thu, 16 Dec 2010 19:27:12 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from lpo-relay-04.vmsinfo.com (lpo-relay-04.vmsinfo.com [216.169.137.115]) by mail.postgresql.org (Postfix) with ESMTP id 2C6D71337B4A for ; Thu, 16 Dec 2010 15:27:12 -0400 (AST) X-IronPort-AV: E=Sophos;i="4.59,356,1288584000"; d="scan'208";a="27575933" Received: from unknown (HELO lpo-mailbox-02.vmsinfo.com) ([216.169.137.251]) by lpo-relay-04.vmsinfo.com with ESMTP; 16 Dec 2010 14:27:09 -0500 Received: from [10.101.43.35] (lpo-autonomy-p03.vmsinfo.com [216.169.135.234]) by lpo-mailbox-02.vmsinfo.com (Postfix) with ESMTP id CF89856258; Thu, 16 Dec 2010 14:27:08 -0500 (EST) Message-ID: <4D0A680C.7040105@vmsinfo.com> Date: Thu, 16 Dec 2010 14:27:08 -0500 From: Mladen Gogala Organization: VMS User-Agent: Thunderbird 2.0.0.24 (X11/20101027) MIME-Version: 1.0 To: Dave Crooke CC: "Plugge, Joe R." , John W Strange , "pgsql-performance@postgresql.org" Subject: Re: Index Bloat - how to tell? References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.91 tagged_above=-10 required=5 tests=BAYES_00=-1.9, T_RP_MATCHES_RCVD=-0.01 X-Spam-Level: X-Archive-Number: 201012/200 X-Sequence-Number: 41652 Dave Crooke wrote: > There is a plugin called pgstattuple which can be quite informative > .... however, it actually does a full scan of the table / index files, > which may be a bit invasive depending on your environment and load. > > http://www.postgresql.org/docs/current/static/pgstattuple.html > > It's in the contrib (at least for 8.4), and so you have to import its > functions into your schema using the script in the contrib directory. > > Cheers > Dave I tried it with one of my databases: testtrack=# select * from pgstatindex('public.defects_pkey'); version | tree_level | index_size | root_block_no | internal_pages | leaf_pages | empty_pages | deleted_pages | avg_leaf_density | leaf_fragmentation ---------+------------+------------+---------------+----------------+------------+-------------+---------------+------------------+------------------- - 2 | 1 | 827392 | 3 | 0 | 100 | 0 | 0 | 70.12 | 22 (1 row) What is "leaf_fragmentation"? How is it defined? I wasn't able to find out any definition of that number. How is it calculated. I verified that running reindex makes it 0: testtrack=# reindex table public.defects; REINDEX testtrack=# select * from pgstatindex('public.defects_pkey'); version | tree_level | index_size | root_block_no | internal_pages | leaf_pages | empty_pages | deleted_pages | avg_leaf_density | leaf_fragmentation ---------+------------+------------+---------------+----------------+------------+-------------+---------------+------------------+------------------- - 2 | 1 | 647168 | 3 | 0 | 78 | 0 | 0 | 89.67 | 0 (1 row) -- Mladen Gogala Sr. Oracle DBA 1500 Broadway New York, NY 10036 (212) 329-5251 http://www.vmsinfo.com The Leader in Integrated Media Intelligence Solutions