1
0
mirror of https://github.com/postgres/postgres.git synced 2025-08-08 06:02:22 +03:00

Add index information to /contrib/pgstattuple:

This is an extension of pgstattuple to query information from indexes.
It supports btree, hash and gist. Gin is not supported. It scans only
index pages and does not read corresponding heap tuples. Therefore,
'dead_tuple' means the number of tuples with LP_DELETE flag.

Also, I added an experimental feature for btree indexes. It checks
fragmentation factor of indexes. If an leaf has the right link on the
next adjacent page in the file, it is assumed to be continuous (not
fragmented). It will help us to decide when to REINDEX.

ITAGAKI Takahiro
This commit is contained in:
Bruce Momjian
2006-07-06 02:18:07 +00:00
parent 591e90a4d9
commit dab42382f4
3 changed files with 449 additions and 124 deletions

View File

@@ -2,8 +2,8 @@ pgstattuple README 2002/08/29 Tatsuo Ishii
1. What is pgstattuple?
pgstattuple returns the table length, percentage of the "dead"
tuples of a table and other info. This may help users to determine
pgstattuple returns the relation length, percentage of the "dead"
tuples of a relation and other info. This may help users to determine
whether vacuum is necessary or not. Here is an example session:
test=# \x
@@ -23,7 +23,7 @@ free_percent | 1.95
Here are explanations for each column:
table_len -- physical table length in bytes
table_len -- physical relation length in bytes
tuple_count -- number of live tuples
tuple_len -- total tuples length in bytes
tuple_percent -- live tuples in %
@@ -40,7 +40,7 @@ free_percent -- free space in %
3. Using pgstattuple
pgstattuple may be called as a table function and is
pgstattuple may be called as a relation function and is
defined as follows:
CREATE OR REPLACE FUNCTION pgstattuple(text) RETURNS pgstattuple_type
@@ -51,14 +51,20 @@ free_percent -- free space in %
AS 'MODULE_PATHNAME', 'pgstattuplebyid'
LANGUAGE C STRICT;
The argument is the table name (optionally it may be qualified)
or the OID of the table. Note that pgstattuple only returns
The argument is the relation name (optionally it may be qualified)
or the OID of the relation. Note that pgstattuple only returns
one row.
4. Notes
pgstattuple acquires only a read lock on the table. So concurrent
pgstattuple acquires only a read lock on the relation. So concurrent
update may affect the result.
pgstattuple judges a tuple is "dead" if HeapTupleSatisfiesNow()
returns false.
5. History
2006/06/28
Extended to work against indexes.