Resizing postgres does not update work_mem

I created a fly.io postgres instance using flyctl. Recently I resized the memory of the instance from 1GB to 3GB. However, the work_mem postgres parameter was not updated (it is still 4mb). Based on my reading of the default fly.io postgres configuration (postgres-ha/config.go at d50f69154cce51f807245360f30b9317c1738dca · fly-apps/postgres-ha · GitHub) it should be set to 48mb.

It seemed like resizing the instance restarted the instance, so I assume the parameters should have been updated. Is there some additional step I am missing?

It would be nice if the CLI updated that. But given your finding, it sounds like it doesn’t.

My understanding (based on creating GitHub - gregmsanderson/postgres-ha-timescaledb: Postgres + Stolon for HA clusters as Fly apps with Timescaledb) is those parameters are only set when you first create the postgres instance/cluster.

The good news is I found you can edit those parameters afterwards by doing a stolen update e.g I did this:

fly ssh console
export $(cat /data/.env | xargs)
stolonctl update --patch '{"pgParameters": { "shared_preload_libraries": "timescaledb"}}'
exit

… so you would change that to have your name:value in that JSON on line three.

1 Like

Thanks for the very thorough answer Greg! I will try this early next week and update with my findings.

Ended up deploying it today and it worked great! Thanks!

1 Like