默认情况下,pg_freespacemap是没有安装的,这个时候,直接去使用,会报错:
postgres@:5432/postgres-96307#=select * from pg_freespace('student');
ERROR: function pg_freespace(unknown) does not exist
LINE 1: select * from pg_freespace('student');
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
需要我们创建 EXTENSION pg_freespacemap
步骤如下:
1.切换到ROOT用户
su - root
2.进入到源码的contrib/pg_freespacemap目录
cd /postgresql/soft/postgresql-16.1/contrib/pg_freespacemap
[root@dbserver1 ~]# cd /postgresql/soft/postgresql-16.1/contrib/pg_freespacemap
6.列出所有的extension
postgres@:5432/postgres-96497#=\dx
List of installed extensions
Name | Version | Schema | Description
--------------------+---------+------------+------------------------------------------------------------------------
pg_buffercache | 1.4 | public | examine the shared buffer cache
pg_freespacemap | 1.2 | public | examine the free space map (FSM)
pg_stat_statements | 1.10 | public | track planning and execution statistics of all SQL statements executed
pg_visibility | 1.2 | public | examine the visibility map (VM) and page-level visibility info
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(5 rows)