gpt4 book ai didi

postgresql - pg_stat_statements 启用,但表不存在

转载 作者:行者123 更新时间:2023-11-29 11:11:24 27 4
gpt4 key购买 nike

我已经启动并运行了 postgresql-9.4,并且最近在官方的帮助下启用了 pg_stat_statements 模块 documentation .

但我在使用时遇到以下错误:

postgres=# SELECT * FROM pg_stat_statements;
ERROR: relation "pg_stat_statements" does not exist
LINE 1: SELECT * FROM pg_stat_statements;


postgres=# SELECT pg_stat_statements_reset();
ERROR: function pg_stat_statements_reset() does not exist
LINE 1: SELECT pg_stat_statements_reset();

我使用 postgres 用户登录到 psql。我还检查了可用的扩展列表:

postgres=# SELECT * FROM pg_available_extensions WHERE name = 'pg_stat_statements'
;
name | default_version | installed_version | comment
--------------------+-----------------+-------------------+-----------------------------------------------------------
pg_stat_statements | 1.2 | | track execution statistics of all SQL statements executed
(1 row)

下面是扩展版本查询的结果:

postgres=# SELECT * FROM pg_available_extension_versions WHERE name = 'pg_stat_statements';
name | version | installed | superuser | relocatable | schema | requires | comment
--------------------+---------+-----------+-----------+-------------+--------+----------+-----------------------------------------------------------
pg_stat_statements | 1.2 | f | t | t | | | track execution statistics of all SQL statements executed
(1 row)

我们将不胜感激。

最佳答案

未安装扩展:

SELECT * 
FROM pg_available_extensions
WHERE
name = 'pg_stat_statements' and
installed_version is not null;

如果表为空,创建扩展:

CREATE EXTENSION pg_stat_statements;

关于postgresql - pg_stat_statements 启用,但表不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31021174/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com