Skip to content

Commit

Permalink
Add vacuum_buffer_usage_limit and min_dynamic_shared_memory, increase…
Browse files Browse the repository at this point in the history
… autovacuum_vacuum_cost_limit if ssd
  • Loading branch information
anayrat authored and jocelynj committed Apr 12, 2024
1 parent 43da2ec commit bbdae50
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
21 changes: 21 additions & 0 deletions roles/postgresql/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ shared_buffers: "{{ var1 | map('int')| min }}"

work_mem: "64MB"

min_dynamic_shared_memory: >-
{% if ansible_memtotal_mb < 4096 %}
0
{% elif ansible_memtotal_mb >= 4096 and ansible_memtotal_mb < 8192 %}
256MB
{% elif ansible_memtotal_mb >= 8192 and ansible_memtotal_mb < 16384 %}
512MB
{% elif ansible_memtotal_mb >= 16384 and ansible_memtotal_mb < 32768 %}
1GB
{% elif ansible_memtotal_mb >= 32768 %}
2GB
{% endif %}
bgwriter_delay: 200
bgwriter_lru_maxpages: 100
bgwriter_lru_multiplier: 2.0
Expand Down Expand Up @@ -46,6 +60,13 @@ effective_cache_size: "{{ (ansible_memtotal_mb * 1024 / 3 / 8) | int }}"
# https://github.com/MagicStack/asyncpg/issues/530
jit: "false"

autovacuum_vacuum_cost_limit: >-
{% if ssd %}
400
{% else %}
-1
{% endif %}
log_min_duration_statement: "10s"
auto_explain_log_min_duration: "60s"
shared_preload_libraries: "'pg_stat_statements'"
Expand Down
8 changes: 8 additions & 0 deletions roles/postgresql/templates/postgresql-config
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ maintenance_work_mem = 1GB

work_mem = {{ work_mem }}
wal_buffers = 128MB
{% if postgres_info.version.major > 13 %}
min_dynamic_shared_memory ={{ min_dynamic_shared_memory }}
{% endif %}

{% if postgres_info.version.major < 15 %}
hash_mem_multiplier = 2.0
Expand Down Expand Up @@ -45,6 +48,11 @@ effective_cache_size = {{ effective_cache_size }}
# https://github.com/MagicStack/asyncpg/issues/530
jit = {{ jit }}

autovacuum_vacuum_cost_limit ={{ autovacuum_vacuum_cost_limit }}
{% if postgres_info.version.major > 15 %}
vacuum_buffer_usage_limit = 2MB
{% endif %}


synchronous_commit = {{ synchronous_commit }}
# On n'utilise pas la réplication ni le Point In Time Recovery
Expand Down

0 comments on commit bbdae50

Please sign in to comment.