pgstattuple (一)

瀚高数据库需要先安装pgstattuple拓展模块:

CREATE EXTENSION
highgo=# \dx
                   List of installed extensions
    Name     | Version |   Schema   |         Description          
-------------+---------+------------+------------------------------
 highgo_x    | 9.5.7   | pg_catalog | Make it fly
 pgstattuple | 1.3     | public     | show tuple-level statistics
 plpgsql     | 1.0     | pg_catalog | PL/pgSQL procedural language
(3 rows)


highgo=# SELECT * FROM pgstattuple('pg_catalog.pg_proc');
 table_len | tuple_count | tuple_len | tuple_percent | dead_tuple_count | dead_tuple_len | dead_tuple_percent | free_space | free_percent 
-----------+-------------+-----------+---------------+------------------+----------------+--------------------+------------+--------------
    688128 |        3294 |    646866 |            94 |                0 |              0 |                  0 |      14692 |         2.14
(1 row)

highgo=# \x
Expanded display is on.
highgo=# SELECT * FROM pgstattuple('pg_catalog.pg_proc');
-[ RECORD 1 ]------+-------
table_len          | 688128
tuple_count        | 3294
tuple_len          | 646866
tuple_percent      | 94
dead_tuple_count   | 0
dead_tuple_len     | 0
dead_tuple_percent | 0
free_space         | 14692
free_percent       | 2.14

pgstattuple 输出列如下:

   Column           Type        Description
table_len          bigint     Physical relation length in bytes
tuple_count        bigint     Number of live tuples
tuple_len          bigint     Total length of live tuples in bytes
tuple_percent      float8     Percentage of live tuples
dead_tuple_count   bigint     Number of dead tuples
dead_tuple_len     bigint     Total length of dead tuples in bytes
dead_tuple_percent float8     Percentage of dead tuples
free_space         bigint     Total free space in bytes
free_percent       float8     Percentage of free space
    字段              类型            描述
table_len           bigint       物理关系长度,以字节计
tuple_count         bigint       活的元组的数量
tuple_len           bigint       活的元组的总长度,以字节计
tuple_percent       float8       活的元组的百分比
dead_tuple_count    bigint       死的元组的数量
dead_tuple_len      bigint       死的元组的总长度,以字节计
dead_tuple_percent  float8       死的元组的百分比
free_space          bigint       空闲空间总量,以字节计
free_percent        float8       空闲空间的百分比

Note: The table_len will always be greater than the sum of the tuple_len, dead_tuple_len and free_space. The difference is accounted for by fixed page overhead, the per-page table of pointers to tuples, and padding to ensure that tuples are correctly aligned.

BY 海无涯

你可能感兴趣的:(Highgo,DB)