diff --git a/defaults/main.yaml b/defaults/main.yaml index b280537..1d4630c 100644 --- a/defaults/main.yaml +++ b/defaults/main.yaml @@ -34,11 +34,13 @@ postgresql_recovery_target_time: "" postgresql_promote_trigger_file: "{{ postgresql_data_dir }}/promote.trigger" postgresql_password_encryption_algorithm: "scram-sha-256" +postgresql_max_connections: '1000' +postgresql_storage_type: 'ssd' postgresql_default_parameters: data_directory: '{{ postgresql_data_dir }}' archive_mode: "{{ postgresql_archive_mode | default('on') }}" listen_addresses: '*' - max_connections: '1000' + max_connections: '{{ postgresql_max_connections }}' superuser_reserved_connections: '5' shared_buffers: '{{ (ansible_memory_mb.real.total * 0.25) | round | int }}MB' huge_pages: 'try' @@ -47,8 +49,14 @@ postgresql_default_parameters: max_parallel_workers: '{{ ansible_processor_vcpus }}' max_parallel_workers_per_gather: '{{ (ansible_processor_vcpus / 2) | round | int }}' max_parallel_maintenance_workers: '{{ (ansible_processor_vcpus / 2) | round | int }}' - max_wal_size: '1GB' - min_wal_size: '80MB' + work_mem: '{{ (((ansible_memory_mb.real.total - ((ansible_memory_mb.real.total * 0.25) | round | int)) / (postgresql_max_connections | int * 3) / ((ansible_processor_vcpus / 2) | round | int)) + 4) | round | int }}MB' + maintenance_work_mem: '{{ (ansible_memory_mb.real.total * 0.0625) | round | int }}MB' + effective_cache_size: '{{ (ansible_memory_mb.real.total * 0.8) | round | int }}MB' + random_page_cost: "{{ '1.1' if postgresql_storage_type == 'ssd' else '4' }}" + effective_io_concurrency: "{{ '200' if postgresql_storage_type == 'ssd' else '2' }}" + min_wal_size: '1GB' + max_wal_size: '4GB' + wal_buffers: '16MB' log_destination: 'stderr' logging_collector: 'on' log_directory: 'log'