Updated `dc-infra.yaml` to enable automatic restart (`unless-stopped`), introduce dynamic memory allocations via environment variables, and adjust healthcheck intervals for reduced load. Enhanced `postgresql.conf` with performance tuning comments, schema search path inclusion for Keycloak and app users, and SSL adjustments for internal communication.
96 lines
2.9 KiB
Plaintext
96 lines
2.9 KiB
Plaintext
# PostgreSQL Configuration File
|
|
# Optimized for Meldestelle application
|
|
|
|
# Alle anderen Performance-Werte (shared_buffers etc.) können hier auf
|
|
# den niedrigen Werten bleiben, da sie durch den 'command' oben
|
|
# in der docker-compose dynamisch überschrieben werden.
|
|
|
|
# Connection Settings
|
|
listen_addresses = '*'
|
|
max_connections = 100
|
|
superuser_reserved_connections = 3
|
|
|
|
# Memory Settings
|
|
# These will be overridden by environment variables in docker-compose.yaml
|
|
shared_buffers = 256MB # min 128kB
|
|
work_mem = 16MB # min 64kB
|
|
maintenance_work_mem = 64MB # min 1MB
|
|
effective_cache_size = 768MB
|
|
|
|
# Write-Ahead Log (WAL)
|
|
wal_level = replica # minimal, replica, or logical
|
|
max_wal_size = 1GB
|
|
min_wal_size = 80MB
|
|
wal_buffers = 16MB # min 32kB, -1 sets based on shared_buffers
|
|
checkpoint_completion_target = 0.9 # checkpoint target duration, 0.0 - 1.0
|
|
random_page_cost = 1.1 # For SSD storage
|
|
|
|
# Background Writer
|
|
bgwriter_delay = 200ms
|
|
bgwriter_lru_maxpages = 100
|
|
bgwriter_lru_multiplier = 2.0
|
|
|
|
# Asynchronous Behavior
|
|
effective_io_concurrency = 200 # For SSD storage
|
|
max_worker_processes = 8
|
|
max_parallel_workers_per_gather = 4
|
|
max_parallel_workers = 8
|
|
max_parallel_maintenance_workers = 4
|
|
|
|
# Query Planner
|
|
default_statistics_target = 100
|
|
constraint_exclusion = partition
|
|
|
|
# Logging
|
|
log_destination = 'stderr'
|
|
logging_collector = off
|
|
# log_directory = 'log'
|
|
# log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log'
|
|
log_truncate_on_rotation = off
|
|
log_rotation_age = 1d
|
|
log_rotation_size = 100MB
|
|
log_min_duration_statement = 250ms # Log slow queries (250ms or slower)
|
|
log_checkpoints = on
|
|
log_connections = on
|
|
log_disconnections = on
|
|
log_lock_waits = on
|
|
log_temp_files = 0
|
|
log_autovacuum_min_duration = 250ms
|
|
log_line_prefix = '%m [%p] %q%u@%d '
|
|
|
|
# Autovacuum
|
|
autovacuum = on
|
|
autovacuum_max_workers = 3
|
|
autovacuum_naptime = 1min
|
|
autovacuum_vacuum_threshold = 50
|
|
autovacuum_analyze_threshold = 50
|
|
autovacuum_vacuum_scale_factor = 0.05
|
|
autovacuum_analyze_scale_factor = 0.025
|
|
autovacuum_vacuum_cost_delay = 20ms
|
|
autovacuum_vacuum_cost_limit = 2000
|
|
|
|
# OPTIMIERUNG: Search Path für Keycloak und App-User
|
|
# Postgres sucht erst im Schema des Users, dann in public, dann in keycloak.
|
|
search_path = '"$user", public, keycloak'
|
|
row_security = on
|
|
|
|
# Client Connection Defaults
|
|
client_min_messages = notice
|
|
statement_timeout = 60000 # 60 seconds, prevents long-running queries
|
|
lock_timeout = 10000 # 10 seconds, prevents lock contention
|
|
idle_in_transaction_session_timeout = 600000 # 10 minutes, prevents idle transactions
|
|
|
|
# Disk
|
|
temp_file_limit = 1GB # Limits temp file size
|
|
|
|
# OPTIMIERUNG: SSL deaktiviert lassen für interne Kommunikation
|
|
ssl = off
|
|
ssl_prefer_server_ciphers = on
|
|
|
|
# Performance Monitoring
|
|
track_activities = on
|
|
track_counts = on
|
|
track_io_timing = on
|
|
track_functions = pl # none, pl, all
|
|
track_activity_query_size = 2048
|