使用Google Cloud SQL重置pg

编程入门 行业动态 更新时间:2024-10-11 11:22:46
本文介绍了使用Google Cloud SQL重置pg_stat_statements的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在使用在Google Cloud SQL中运行的PostgreSQL实例。

I am using a PostgreSQL instance running in Google Cloud SQL.

我试图重置pg_stat_statements,因为我们对表进行了改进并添加了一些索引。不幸的是,当我尝试使用主要的 postgres 用户运行以下命令时:

I am trying to reset the pg_stat_statements because we made improvements to our tables and added some index. Unfortunately, when I try to run the following command using the main postgres user:

select pg_stat_reset();

我收到以下错误消息:

ERROR: permission denied for function pg_stat_reset

的权限被拒绝托管服务和一些事情需要解决,但是能够重置pg_stat以便调整数据库很重要。基本上,如果您进行更改,则需要能够重置pg_stat,以使其更改前的输出不会受到数据的污染。即使在托管服务中,这种调整也是至关重要的。

I understand that it's a managed service and some things need to be walled off, but it's important to be able to reset pg_stat so you can tune the database. Basically if you make a change, you need to be able to reset pg_stat so that its output isn't polluted from data prior to the change. Even in a managed service, this kind of tuning is critical to be able to do.

任何人都知道如何将其与Google Cloud SQL配合使用吗?

Anyone know how I can get this to work with Google Cloud SQL?

谢谢。

推荐答案

我能够向GoogleCloud支持人员咨询此事,这里是他们获得的回报:

I was able to ask GoogleCloud Support about this and here's what they got back with:

pg_stat_reset()需要超级用户特权。但是 CloudSQL不支持它。我们建议您使用pg_stat_statements_reset()函数代替重置统计信息。为此,要从Cloud Console创建的用户(即默认PostgreSQL用户),或者应由默认 PostgreSQL用户通过执行以下命令授予对该功能的 EXECUTE权限命令:授予在函数pg_stat_statements_reset()上执行的权限;

pg_stat_reset() needs superuser privileges. But it is not supported in CloudSQL. We recommand that you use pg_stat_statements_reset() function instead to reset the statistics. To do this, either user has to be created from Cloud Console (i.e. Default PostgreSQL user), or EXECUTE permission on this function should be granted by a default PostgreSQL user by executing the following command: grant execute on function pg_stat_statements_reset() to ;

我能够使用postgres用户成功使用此命令。请注意,此功能必须在启用pg_stat_statement的数据库上运行。

I was able to use this command successfully using the postgres user. Note that this function must be run on the database where pg_stat_statement was enabled.

更多推荐

使用Google Cloud SQL重置pg

本文发布于:2023-07-21 07:28:10,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1175434.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Cloud   Google   pg   SQL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!