Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Cloud SQL for PostgreSQL `work_mem`

there. I want to tune Google Cloud SQL for PostgreSQL instance. Currently, I'm trying to eliminate sorting speed degradation:

Sort Method: external merge Disk: 39592kB 

Right now work_mem is set to 4MB, and it seems that is too small. After reading docs, I didn't find the way how to change this setting. It's impossible via Web GUI and via command line:

$ 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.

Any thoughts on that?

like image 214
sashaegorov Avatar asked Mar 18 '26 01:03

sashaegorov


1 Answers

You can change it by user or by database.

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

User overides db, db overrides postgresql.conf / cluster settings. Both override alter system set ... which you might not be able to use due to security settings.

like image 59
Scott Marlowe Avatar answered Mar 20 '26 16:03

Scott Marlowe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!