适用于PostgreSQL的Google Cloud SQL`work_mem`

时间:2018-01-09 10:21:42

标签: postgresql google-cloud-sql

那里。我想调整 Google Cloud SQL for PostgreSQL 实例。目前,我正试图消除排序速度降低:

Sort Method: external merge Disk: 39592kB 

现在work_mem设置为4MB,似乎太小了。阅读文档后,我没有找到如何更改此设置的方法。通过Web GUI和命令行无法实现:

$ gcloud sql instances patch reporting-dev --database-flags work_mem=128MB
The following message will be used for the patch API method.
{"project": "xxx-153410", "name": "reporting-dev", "settings": {"databaseFlags": [{"name": "work_mem", "value": "128MB"}]}}
WARNING: This patch modifies a value that requires your instance to be
 restarted. Submitting this patch will immediately restart your
instance if it's running.

Do you want to continue (Y/n)?  Y

ERROR: (gcloud.sql.instances.patch) HTTPError 404: Flag requested cannot be set.

对此有何看法?

1 个答案:

答案 0 :(得分:2)

您可以按用户或数据库进行更改。

alter database db1 set work_mem='64MB';
alter user stan set work_mem='32MB';

用户覆盖db,db覆盖postgresql.conf / cluster设置。两者都覆盖alter system set ...由于安全设置,您可能无法使用它。