R
Railway4mo ago
Kurdiez

Setting larger `maintenance_work_mem` for Postgres DB container

We needed larger maintenance_work_mem for our production Postgres DB. This is because we have millions of records and needed to adjust indexes. Our maintenance_work_mem was previously 68MB. We set this by running the following SQL
SET maintenance_work_mem = '1GB';
SET maintenance_work_mem = '1GB';
If the Railway service is restarted and therefore the Postgres is restarted, we won't have that set again. How can we permanently set that value as part of config? Is there an environment variable we should be using?
Solution:
from the postgres docs, it seems like you want to be using ALTER SYSTEM and then re-deploying - https://www.postgresql.org/docs/current/sql-altersystem.html...
Jump to solution
8 Replies
Percy
Percy4mo ago
Project ID: 3747f720-8c9c-4d81-9b13-1e420ceabd6c
Kurdiez
KurdiezOP4mo ago
3747f720-8c9c-4d81-9b13-1e420ceabd6c
Solution
Brody
Brody4mo ago
from the postgres docs, it seems like you want to be using ALTER SYSTEM and then re-deploying - https://www.postgresql.org/docs/current/sql-altersystem.html
Brody
Brody4mo ago
for reference here is the docs on the SET command - https://www.postgresql.org/docs/current/sql-set.html
Kurdiez
KurdiezOP4mo ago
@Brody yeah but that command will write configs to postgresql.auto.conf file. Where is that file exactly? would it be reliable even if I say upgrade Postgres container to a different one?
Brody
Brody4mo ago
well I know the postgresql.conf file is stored on the volume, so I can't imagine the auto file wouldn't be, aka the settings will persist between deployments
Kurdiez
KurdiezOP4mo ago
ok cool thank you.
Brody
Brody4mo ago
let me know if that doesn't work for you though
Want results from more Discord servers?
Add your server