安装过程如下:进入安装包的contrib/pg_stat_statements目录,执行编译和安装动作:
[root@server pg_stat_statements]# pwd /soft/postgresql-9.1.2/contrib/pg_stat_statements [root@server pg_stat_statements]# make && make install make: `all'
/bin/mkdir -p '/usr/local/pgsql/lib' /bin/mkdir -p '/usr/local/pgsql/share/extension' /bin/sh ../../config/install-sh -c -m 755 pg_stat_statements.so '/usr/local/pgsql/lib/pg_stat_statements.so' /bin/sh ../../config/install-sh -c -m 644 ./pg_stat_statements.control '/usr/local/pgsql/share/extension/' /bin/sh ../../config/install-sh -c -m 644 ./pg_stat_statements--1.0.sql ./pg_stat_statements--unpackaged--1.0.sql '/usr/local/pgsql/share/extension/' [root@server pg_stat_statements]#
然后,由于pg_stat_statements 既使用了hook,同时又是以 extension 形式被使用,所以需要再作两件事情:
A: 在postgresql.conf中,进行配置:
shared_preload_libraries = 'pg_stat_statements' # (change requires restart) custom_variable_classes = 'pg_stat_statements' pg_stat_statements.max = 1000 pg_stat_statements.track = top pg_stat_statements.track_utility = true pg_stat_statements.save = true