diff --git a/README.md b/README.md index 5a4746f..a3384f7 100644 --- a/README.md +++ b/README.md @@ -46,12 +46,22 @@ Open http://dhis2-127-0-0-1.nip.io in your favourite browser. Custom configuration for Postgresql can be done by adding to the files in the `./config/postgresql/conf.d/` directory. If your configuration doesn't belong in either of the existing files, you can create a new file. However, it's advised not to make changes to the [postgresql.conf](config/postgresql/postgresql.conf) file. -Any changes to these files won't take effect until the container is restarted or the below command is executed: +Some postgresql configuration parameters can be applied by reloading the configuration. Others will only take effect when the database is restarted. The detailed description of each configuration option (on postgresql v16) is avalable [here](https://www.postgresql.org/docs/16/runtime-config.html). The documentation for each setting generally indicates whether the setting requires a restart in order to take effect. + +A configuration reload can be triggered by executing the following SQL command: ```sql SELECT pg_reload_conf(); ``` +If you need to restart the database server, it is safest to stop the application container first, restart the database, then start the application again. This will mean some minutes of downtime for your users so it is best to co-ordinate such operations with users or execute during quiet times of the day. A typical sequence might look like: + +```bash +docker compose stop app +docker compose restart database +docker compose start app +``` + ## Overlays ### Traefik Dashboard diff --git a/config/postgresql/conf.d/10-memory.conf b/config/postgresql/conf.d/10-memory.conf index 86d1a69..1dbb1c5 100644 --- a/config/postgresql/conf.d/10-memory.conf +++ b/config/postgresql/conf.d/10-memory.conf @@ -3,4 +3,7 @@ work_mem = 16MB # memory per sort/hash operation maintenance_work_mem = 128MB effective_cache_size = 6GB # usually ~75% of RAM +# for locally attached spinning disk +random_page_cost = 1.1 + # max_wal_size = 5GB diff --git a/config/postgresql/conf.d/30-logging.conf b/config/postgresql/conf.d/30-logging.conf index 986e6cd..bc0742b 100644 --- a/config/postgresql/conf.d/30-logging.conf +++ b/config/postgresql/conf.d/30-logging.conf @@ -1,5 +1,5 @@ log_destination = 'stderr' logging_collector = off # disable writing to files -log_statement = 'ddl' # or 'all' if you want full query logging -log_min_duration_statement = 500 # log queries slower than 500ms +log_statement = 'none' # or 'all' if you want full query logging +log_min_duration_statement = 300s # log queries slower than 5 minutes log_timezone = 'UTC' diff --git a/config/postgresql/conf.d/40-wal.conf b/config/postgresql/conf.d/40-wal.conf new file mode 100644 index 0000000..75fef0a --- /dev/null +++ b/config/postgresql/conf.d/40-wal.conf @@ -0,0 +1,3 @@ +checkpoint_completion_target = 0.8 +synchronous_commit = off +wal_writer_delay = 10000ms diff --git a/config/postgresql/postgresql.conf b/config/postgresql/postgresql.conf index bac11f8..62fcd32 100644 --- a/config/postgresql/postgresql.conf +++ b/config/postgresql/postgresql.conf @@ -1,2 +1,11 @@ +# These settings are required to run DHIS2 +# Make local customisations under /etc/postgresql/conf.d listen_addresses = '*' + +# affects the performance of program indicators +jit = off + +# required for flyway +max_locks_per_transaction = 128 + include_dir = '/etc/postgresql/conf.d'