codekingpro/portable-devtools
115k
1/* contrib/pgstattuple/pgstattuple--1.4.sql */2 3-- complain if script is sourced in psql, rather than via CREATE EXTENSION4\echo Use "CREATE EXTENSION pgstattuple" to load this file. \quit5 6CREATE FUNCTION pgstattuple(IN relname text,7 OUT table_len BIGINT, -- physical table length in bytes8 OUT tuple_count BIGINT, -- number of live tuples9 OUT tuple_len BIGINT, -- total tuples length in bytes10 OUT tuple_percent FLOAT8, -- live tuples in %11 OUT dead_tuple_count BIGINT, -- number of dead tuples12 OUT dead_tuple_len BIGINT, -- total dead tuples length in bytes13 OUT dead_tuple_percent FLOAT8, -- dead tuples in %14 OUT free_space BIGINT, -- free space in bytes15 OUT free_percent FLOAT8) -- free space in %16AS 'MODULE_PATHNAME', 'pgstattuple'17LANGUAGE C STRICT PARALLEL SAFE;18 19CREATE FUNCTION pgstatindex(IN relname text,20 OUT version INT,21 OUT tree_level INT,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)30AS 'MODULE_PATHNAME', 'pgstatindex'31LANGUAGE C STRICT PARALLEL SAFE;32 33CREATE FUNCTION pg_relpages(IN relname text)34RETURNS BIGINT35AS 'MODULE_PATHNAME', 'pg_relpages'36LANGUAGE C STRICT PARALLEL SAFE;37 38/* New stuff in 1.1 begins here */39 40CREATE FUNCTION pgstatginindex(IN relname regclass,41 OUT version INT4,42 OUT pending_pages INT4,43 OUT pending_tuples BIGINT)44AS 'MODULE_PATHNAME', 'pgstatginindex'45LANGUAGE C STRICT PARALLEL SAFE;46 47/* New stuff in 1.2 begins here */48 49CREATE FUNCTION pgstattuple(IN reloid regclass,50 OUT table_len BIGINT, -- physical table length in bytes51 OUT tuple_count BIGINT, -- number of live tuples52 OUT tuple_len BIGINT, -- total tuples length in bytes53 OUT tuple_percent FLOAT8, -- live tuples in %54 OUT dead_tuple_count BIGINT, -- number of dead tuples55 OUT dead_tuple_len BIGINT, -- total dead tuples length in bytes56 OUT dead_tuple_percent FLOAT8, -- dead tuples in %57 OUT free_space BIGINT, -- free space in bytes58 OUT free_percent FLOAT8) -- free space in %59AS 'MODULE_PATHNAME', 'pgstattuplebyid'60LANGUAGE C STRICT PARALLEL SAFE;61 62CREATE FUNCTION pgstatindex(IN relname regclass,63 OUT version INT,64 OUT tree_level INT,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)73AS 'MODULE_PATHNAME', 'pgstatindexbyid'74LANGUAGE C STRICT PARALLEL SAFE;75 76CREATE FUNCTION pg_relpages(IN relname regclass)77RETURNS BIGINT78AS 'MODULE_PATHNAME', 'pg_relpagesbyid'79LANGUAGE C STRICT PARALLEL SAFE;80 81/* New stuff in 1.3 begins here */82 83CREATE FUNCTION pgstattuple_approx(IN reloid regclass,84 OUT table_len BIGINT, -- physical table length in bytes85 OUT scanned_percent FLOAT8, -- what percentage of the table's pages was scanned86 OUT approx_tuple_count BIGINT, -- estimated number of live tuples87 OUT approx_tuple_len BIGINT, -- estimated total length in bytes of live tuples88 OUT approx_tuple_percent FLOAT8, -- live tuples in % (based on estimate)89 OUT dead_tuple_count BIGINT, -- exact number of dead tuples90 OUT dead_tuple_len BIGINT, -- exact total length in bytes of dead tuples91 OUT dead_tuple_percent FLOAT8, -- dead tuples in % (based on estimate)92 OUT approx_free_space BIGINT, -- estimated free space in bytes93 OUT approx_free_percent FLOAT8) -- free space in % (based on estimate)94AS 'MODULE_PATHNAME', 'pgstattuple_approx'95LANGUAGE C STRICT PARALLEL SAFE;96 