pg_freespacemap

pg_freespacemap 可以看到表或索引的每个页面和对应的空闲空间映射(FSM)的内容。

版本

# cat /etc/centos-release
CentOS Linux release 7.4.1708 (Core) 
# su - postgres
Last login: Mon Oct 21 11:01:23 CST 2019 on pts/0

$ psql -c "select version();"
                                                 version                                                 
---------------------------------------------------------------------------------------------------------
 PostgreSQL 11.5 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit
(1 row)

pg_freespacemap

$ cd /usr/pgsql-11/
$ ls -l ./lib/pg_free*
-rwxr-xr-x. 1 root root 7080 Aug  8 06:20 ./lib/pg_freespacemap.so

$ ls -l ./share/extension/pg_free*
-rw-r--r--. 1 root root 335 Aug  8 06:20 ./share/extension/pg_freespacemap--1.0--1.1.sql
-rw-r--r--. 1 root root 377 Aug  8 06:20 ./share/extension/pg_freespacemap--1.1--1.2.sql
-rw-r--r--. 1 root root 899 Aug  8 06:20 ./share/extension/pg_freespacemap--1.1.sql
-rw-r--r--. 1 root root 160 Aug  8 06:20 ./share/extension/pg_freespacemap.control
-rw-r--r--. 1 root root 375 Aug  8 06:20 ./share/extension/pg_freespacemap--unpackaged--1.0.sql

$ psql
psql (11.5)
Type "help" for help.

postgres=#
postgres=# select * from pg_available_extensions where name like 'pg_free%';
      name       | default_version | installed_version |             comment              
-----------------+-----------------+-------------------+----------------------------------
 pg_freespacemap | 1.2             |                   | examine the free space map (FSM)
(1 row)

postgres=# 
postgres=# create extension pg_freespacemap;
CREATE EXTENSION
postgres=# 
postgres=# \dx
                       List of installed extensions
      Name       | Version |   Schema   |           Description            
-----------------+---------+------------+----------------------------------
 pg_freespacemap | 1.2     | public     | examine the free space map (FSM)
 plpgsql         | 1.0     | pg_catalog | PL/pgSQL procedural language
(2 rows)

postgres=# \dxS+ pg_freespacemap
 Objects in extension "pg_freespacemap"
           Object description           
----------------------------------------
 function pg_freespace(regclass)
 function pg_freespace(regclass,bigint)
(2 rows)

postgres=# select * from pg_freespace('public.t_log');
 blkno | avail 
-------+-------
     0 |  8096
(1 row)

参考:
https://www.postgresql.org/docs/11/pgfreespacemap.html

你可能感兴趣的:(extension,pg_freespacemap,#,postgresql,extension)