Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add postgres tuning config #945

Merged
merged 1 commit into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ services:
volumes:
- postgres_db:/var/lib/postgresql/data
- ./indexers/db/docker-entrypoint-initdb.d/init-db.sql:/docker-entrypoint-initdb.d/init-db.sql
- ./indexers/db/postgresql.conf:/etc/postgresql/postgresql.conf
restart: unless-stopped
hostname: postgres
environment:
Expand All @@ -85,6 +86,7 @@ services:
interval: 5s
timeout: 5s
retries: 5
command: ["postgres", "-c", "config_file=/etc/postgresql/postgresql.conf"]

# Hasura GraphQL Engine
hasura:
Expand Down
52 changes: 52 additions & 0 deletions indexers/db/postgresql.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Logging (only enable for debugging, don't leave on as it will degrade performance)
# logging_collector = off
# log_destination = 'stderr'
# log_statement = 'all'
# log_min_duration_statement = 0
# log_line_prefix = '%t [%p]: [%l-1] user=%u,db=%d,app=%a,client=%h '
# log_connections = on
# log_disconnections = on
# log_duration = on

# Connection Settings
max_connections = 500
listen_addresses = '0.0.0.0'
port = 5432

# Memory Settings
shared_buffers = 8GB
effective_cache_size = 24GB
maintenance_work_mem = 2GB
work_mem = 20MB
wal_buffers = 64MB

# Checkpoint Settings
checkpoint_completion_target = 0.9
min_wal_size = 1GB
max_wal_size = 4GB

# Planner Settings
default_statistics_target = 200
random_page_cost = 1.1
effective_io_concurrency = 200

# Parallel Query Settings
max_worker_processes = 16
max_parallel_workers_per_gather = 4
max_parallel_workers = 16
max_parallel_maintenance_workers = 4

# WAL Settings
wal_writer_delay = 200ms
wal_writer_flush_after = 1MB

# Autovacuum Settings
autovacuum_max_workers = 6
autovacuum_naptime = 10s

# Logging and Monitoring
shared_preload_libraries = 'pg_stat_statements'
pg_stat_statements.track = all

# Locking Settings
deadlock_timeout = 1s
Loading