1 /* contrib/pgstattuple/pgstattuple--1.4.sql */
3 -- complain if script is sourced in psql, rather than via CREATE EXTENSION
4 \echo Use "CREATE EXTENSION pgstattuple" to load this file. \quit
6 CREATE FUNCTION pgstattuple(IN relname text,
7 OUT table_len BIGINT, -- physical table length in bytes
8 OUT tuple_count BIGINT, -- number of live tuples
9 OUT tuple_len BIGINT, -- total tuples length in bytes
10 OUT tuple_percent FLOAT8, -- live tuples in %
11 OUT dead_tuple_count BIGINT, -- number of dead tuples
12 OUT dead_tuple_len BIGINT, -- total dead tuples length in bytes
13 OUT dead_tuple_percent FLOAT8, -- dead tuples in %
14 OUT free_space BIGINT, -- free space in bytes
15 OUT free_percent FLOAT8) -- free space in %
16 AS 'MODULE_PATHNAME', 'pgstattuple'
17 LANGUAGE C STRICT PARALLEL SAFE;
19 CREATE FUNCTION pgstatindex(IN relname text,
22 OUT index_size BIGINT,
23 OUT root_block_no BIGINT,
24 OUT internal_pages BIGINT,
25 OUT leaf_pages BIGINT,
26 OUT empty_pages BIGINT,
27 OUT deleted_pages BIGINT,
28 OUT avg_leaf_density FLOAT8,
29 OUT leaf_fragmentation FLOAT8)
30 AS 'MODULE_PATHNAME', 'pgstatindex'
31 LANGUAGE C STRICT PARALLEL SAFE;
33 CREATE FUNCTION pg_relpages(IN relname text)
35 AS 'MODULE_PATHNAME', 'pg_relpages'
36 LANGUAGE C STRICT PARALLEL SAFE;
38 /* New stuff in 1.1 begins here */
40 CREATE FUNCTION pgstatginindex(IN relname regclass,
42 OUT pending_pages INT4,
43 OUT pending_tuples BIGINT)
44 AS 'MODULE_PATHNAME', 'pgstatginindex'
45 LANGUAGE C STRICT PARALLEL SAFE;
47 /* New stuff in 1.2 begins here */
49 CREATE FUNCTION pgstattuple(IN reloid regclass,
50 OUT table_len BIGINT, -- physical table length in bytes
51 OUT tuple_count BIGINT, -- number of live tuples
52 OUT tuple_len BIGINT, -- total tuples length in bytes
53 OUT tuple_percent FLOAT8, -- live tuples in %
54 OUT dead_tuple_count BIGINT, -- number of dead tuples
55 OUT dead_tuple_len BIGINT, -- total dead tuples length in bytes
56 OUT dead_tuple_percent FLOAT8, -- dead tuples in %
57 OUT free_space BIGINT, -- free space in bytes
58 OUT free_percent FLOAT8) -- free space in %
59 AS 'MODULE_PATHNAME', 'pgstattuplebyid'
60 LANGUAGE C STRICT PARALLEL SAFE;
62 CREATE FUNCTION pgstatindex(IN relname regclass,
65 OUT index_size BIGINT,
66 OUT root_block_no BIGINT,
67 OUT internal_pages BIGINT,
68 OUT leaf_pages BIGINT,
69 OUT empty_pages BIGINT,
70 OUT deleted_pages BIGINT,
71 OUT avg_leaf_density FLOAT8,
72 OUT leaf_fragmentation FLOAT8)
73 AS 'MODULE_PATHNAME', 'pgstatindexbyid'
74 LANGUAGE C STRICT PARALLEL SAFE;
76 CREATE FUNCTION pg_relpages(IN relname regclass)
78 AS 'MODULE_PATHNAME', 'pg_relpagesbyid'
79 LANGUAGE C STRICT PARALLEL SAFE;
81 /* New stuff in 1.3 begins here */
83 CREATE FUNCTION pgstattuple_approx(IN reloid regclass,
84 OUT table_len BIGINT, -- physical table length in bytes
85 OUT scanned_percent FLOAT8, -- what percentage of the table's pages was scanned
86 OUT approx_tuple_count BIGINT, -- estimated number of live tuples
87 OUT approx_tuple_len BIGINT, -- estimated total length in bytes of live tuples
88 OUT approx_tuple_percent FLOAT8, -- live tuples in % (based on estimate)
89 OUT dead_tuple_count BIGINT, -- exact number of dead tuples
90 OUT dead_tuple_len BIGINT, -- exact total length in bytes of dead tuples
91 OUT dead_tuple_percent FLOAT8, -- dead tuples in % (based on estimate)
92 OUT approx_free_space BIGINT, -- estimated free space in bytes
93 OUT approx_free_percent FLOAT8) -- free space in % (based on estimate)
94 AS 'MODULE_PATHNAME', 'pgstattuple_approx'
95 LANGUAGE C STRICT PARALLEL SAFE;