db tuning
This commit is contained in:
@@ -56,9 +56,6 @@ UPLOAD_LIMIT=20000000
|
||||
# upper limit for how much RAM you want the DB to use, in megabytes (the same amount of swap will also be allocated to the DB container)
|
||||
DB_MEMORY_LIMIT=5000
|
||||
|
||||
# how long to give Postgres to shut down cleanly on redeploys (too short force-kills it, wiping the statistics that autovacuum depends on)
|
||||
# DB_STOP_GRACE_PERIOD=2m
|
||||
|
||||
# set to true *after* your initial deployment to enable concurrent index creation for faster migrations in future upgrades
|
||||
DB_MIGRATE_INDEXES_CONCURRENTLY=false
|
||||
|
||||
|
||||
+31
-5
@@ -140,6 +140,9 @@ services:
|
||||
restart_policy:
|
||||
condition: on-failure
|
||||
labels:
|
||||
# how long abra waits for the deploy to converge, as needs headroom for DB migrations on upgrades
|
||||
# and the db service's 2m stop_grace_period during redeploys
|
||||
- "coop-cloud.${STACK_NAME}.timeout=${TIMEOUT:-300}"
|
||||
- "backupbot.backup=${ENABLE_BACKUPS:-true}"
|
||||
#- backupbot.backup.volumes.upload-data: "true"
|
||||
#- backupbot.backup.volumes.upload-data.path: "/opt/app/data/uploads"
|
||||
@@ -163,7 +166,7 @@ services:
|
||||
db:
|
||||
image: ${DB_DOCKER_IMAGE}
|
||||
# give Postgres time to shut down cleanly: the Swarm default (10s) force-kills it mid-shutdown on every redeploy, which wipes the cumulative stats (pg_stat_*) that autovacuum's triggers depend on — a root cause of autovacuum never running on big tables
|
||||
stop_grace_period: ${DB_STOP_GRACE_PERIOD:-2m}
|
||||
stop_grace_period: 2m # NOTE: abra validates the schema before env interpolation, so this duration field can't be env-parameterized
|
||||
environment:
|
||||
# - POSTGRES_PASSWORD
|
||||
- POSTGRES_USER=postgres
|
||||
@@ -183,13 +186,36 @@ services:
|
||||
# shm_size: ${DB_MEMORY_LIMIT} # unsupported by docker swarm
|
||||
tmpfs:
|
||||
- /tmp:size=${DB_MEMORY_LIMIT}M
|
||||
# static tuning defaults for deployments NOT using the postgres tuner overlay (NOTE: `compose.postgres.tune.yml` computes these from your system resources instead of hardcoding them, so please use it!)
|
||||
# Notes:
|
||||
# memory defaults are deliberately SAFE-SMALL (fit a 1 or 2GB VPS with the app co-hosted): shared_buffers is allocated at boot and maintenance_work_mem is per vacuum worker, so oversizing can prevent startup or OOM small machines — the tuner overlay right-sizes them instead (~25% / ~6% of the DB's RAM budget);
|
||||
# max_connections is deliberately low because Bonfire's Ecto pool is the connection pooler (~25-50 conns; oversizing shrinks usable work_mem);
|
||||
# jit off = measured per-query compile tax on Bonfire's many-join queries with no benefit;
|
||||
# the autovacuum settings suit Bonfire's soft-delete/append workload where default thresholds never trigger on big tables.
|
||||
command: >
|
||||
postgres
|
||||
-c max_connections=200
|
||||
-c shared_buffers=${DB_MEMORY_LIMIT}MB
|
||||
# -c shared_preload_libraries='pg_stat_statements'
|
||||
-c max_connections=${PG_MAX_CONNECTIONS:-100}
|
||||
-c shared_buffers=${PG_SHARED_BUFFERS_MB:-256}MB
|
||||
-c effective_cache_size=${PG_EFFECTIVE_CACHE_SIZE_MB:-768}MB
|
||||
-c work_mem=${PG_WORK_MEM_MB:-16}MB
|
||||
-c maintenance_work_mem=${PG_MAINTENANCE_WORK_MEM_MB:-128}MB
|
||||
-c random_page_cost=${PG_RANDOM_PAGE_COST:-1.1}
|
||||
-c effective_io_concurrency=${PG_EFFECTIVE_IO_CONCURRENCY:-200}
|
||||
-c jit=${PG_JIT:-off}
|
||||
-c wal_compression=${PG_WAL_COMPRESSION:-lz4}
|
||||
-c default_toast_compression=${PG_TOAST_COMPRESSION:-lz4}
|
||||
-c shared_preload_libraries=${PG_PRELOAD_LIBS:-pg_stat_statements}
|
||||
-c pg_stat_statements.track=all
|
||||
-c track_io_timing=on
|
||||
-c track_activity_query_size=16384
|
||||
-c autovacuum_vacuum_scale_factor=0.05
|
||||
-c autovacuum_vacuum_insert_scale_factor=0.05
|
||||
-c autovacuum_vacuum_cost_limit=1000
|
||||
-c log_autovacuum_min_duration=0
|
||||
-c log_min_duration_statement=${PG_LOG_MIN_DURATION_STATEMENT:-2000}
|
||||
-c log_lock_waits=on
|
||||
-c log_temp_files=0
|
||||
# -c statement_timeout=1800000
|
||||
# -c pg_stat_statements.track=all
|
||||
#entrypoint: ['tail', '-f', '/dev/null'] # uncomment when the Postgres DB is corrupted and won't start
|
||||
deploy:
|
||||
labels:
|
||||
|
||||
@@ -16,7 +16,7 @@ services:
|
||||
# # -c statement_timeout=1800000
|
||||
# # -c pg_stat_statements.track=all
|
||||
# give Postgres time to shut down cleanly: the Swarm default (10s) force-kills it mid-shutdown on every redeploy, which wipes the cumulative stats (pg_stat_*) that autovacuum's triggers depend on — a root cause of autovacuum never running on big tables
|
||||
stop_grace_period: ${DB_STOP_GRACE_PERIOD:-2m}
|
||||
stop_grace_period: 2m # NOTE: abra validates the schema before env interpolation, so this duration field can't be env-parameterized
|
||||
# shm_size: ${DB_MEMORY_LIMIT} # unsupported by docker swarm
|
||||
tmpfs:
|
||||
- /tmp:size=${DB_MEMORY_LIMIT}M
|
||||
@@ -42,10 +42,10 @@ configs:
|
||||
name: ${STACK_NAME}_postgres_entrypoint_${POSTGRES_ENTRYPOINT_VERSION:-v6}
|
||||
file: postgres/postgres-entrypoint.sh
|
||||
postgres_tune:
|
||||
name: ${STACK_NAME}_postgres_tune_${POSTGRES_TUNE_VERSION:-v1}
|
||||
name: ${STACK_NAME}_postgres_tune_${POSTGRES_TUNE_VERSION:-v2}
|
||||
file: postgres/postgres-tune.sh
|
||||
postgres_conf_tmpl:
|
||||
name: ${STACK_NAME}_postgres_conf_tmpl_${POSTGRES_CONF_TMPL_VERSION:-v2}
|
||||
name: ${STACK_NAME}_postgres_conf_tmpl_${POSTGRES_CONF_TMPL_VERSION:-v3}
|
||||
file: postgres/postgres.conf.tmpl
|
||||
bash_envsubst:
|
||||
name: ${STACK_NAME}_bash_envsubst_${BASH_ENVSUBST_VERSION:-v1}
|
||||
|
||||
+119
-52
@@ -25,7 +25,12 @@ readonly STORAGE_HDD="hdd"
|
||||
readonly STORAGE_SAN="san"
|
||||
|
||||
# Auto-detect or use environment variables
|
||||
PG_DB_TYPE="${PG_DB_TYPE:-${DB_TYPE:-oltp}}"
|
||||
# NOTE: default profile is `mixed` (not `oltp`): Bonfire is OLTP plus a tail of analytics-shaped
|
||||
# queries (many-join boundarised feeds/threads), which is exactly PGTune's mixed workload. It also
|
||||
# right-sizes max_connections (100 vs oltp's 300 — Bonfire's Ecto pool is the pooler, ~25-50 conns;
|
||||
# an oversized value wastes RAM headroom and shrinks the computed work_mem, which caused measured
|
||||
# multi-TB temp-file spills in prod).
|
||||
PG_DB_TYPE="${PG_DB_TYPE:-${DB_TYPE:-mixed}}"
|
||||
PG_STORAGE_TYPE="${PG_STORAGE_TYPE:-${DISK_STORAGE_TYPE:-ssd}}"
|
||||
PG_DB_VERSION="${PG_DB_VERSION:-17}"
|
||||
|
||||
@@ -291,33 +296,35 @@ calc_effective_io_concurrency() {
|
||||
}
|
||||
|
||||
# Calculate parallel workers settings
|
||||
# Echoes 4 space-separated values: max_worker_processes max_parallel_workers_per_gather max_parallel_workers max_parallel_maintenance_workers
|
||||
# (single source of truth — generate_env_vars reads these instead of duplicating the logic)
|
||||
calc_parallel_settings() {
|
||||
if [[ $CPU_COUNT -lt 4 ]]; then
|
||||
echo ""
|
||||
return
|
||||
local max_worker_processes max_parallel_workers_per_gather max_parallel_workers max_parallel_maintenance_workers
|
||||
|
||||
if [[ $CPU_COUNT -ge 4 ]]; then
|
||||
local workers_per_gather=$((CPU_COUNT / 2))
|
||||
# Cap at 4 for non-DW workloads
|
||||
if [[ "$PG_DB_TYPE" != "$DB_TYPE_DW" && $workers_per_gather -gt 4 ]]; then
|
||||
workers_per_gather=4
|
||||
fi
|
||||
|
||||
local parallel_maint_workers=$((CPU_COUNT / 2))
|
||||
if [[ $parallel_maint_workers -gt 4 ]]; then
|
||||
parallel_maint_workers=4
|
||||
fi
|
||||
|
||||
max_worker_processes=${PG_MAX_WORKER_PROCESSES:-$CPU_COUNT}
|
||||
max_parallel_workers_per_gather=${PG_MAX_PARALLEL_WORKERS_PER_GATHER:-$workers_per_gather}
|
||||
max_parallel_workers=${PG_MAX_PARALLEL_WORKERS:-$CPU_COUNT}
|
||||
max_parallel_maintenance_workers=${PG_MAX_PARALLEL_MAINTENANCE_WORKERS:-$parallel_maint_workers}
|
||||
else
|
||||
max_worker_processes=${PG_MAX_WORKER_PROCESSES:-8}
|
||||
max_parallel_workers_per_gather=${PG_MAX_PARALLEL_WORKERS_PER_GATHER:-2}
|
||||
max_parallel_workers=${PG_MAX_PARALLEL_WORKERS:-8}
|
||||
max_parallel_maintenance_workers=${PG_MAX_PARALLEL_MAINTENANCE_WORKERS:-2}
|
||||
fi
|
||||
|
||||
local workers_per_gather=$((CPU_COUNT / 2))
|
||||
local max_parallel_workers=${PG_MAX_PARALLEL_WORKERS:-$CPU_COUNT}
|
||||
local max_worker_processes=${PG_MAX_WORKER_PROCESSES:-$CPU_COUNT}
|
||||
|
||||
# Cap at 4 for non-DW workloads
|
||||
if [[ "$PG_DB_TYPE" != "$DB_TYPE_DW" && $workers_per_gather -gt 4 ]]; then
|
||||
workers_per_gather=4
|
||||
fi
|
||||
|
||||
local parallel_maint_workers=$((CPU_COUNT / 2))
|
||||
if [[ $parallel_maint_workers -gt 4 ]]; then
|
||||
parallel_maint_workers=4
|
||||
fi
|
||||
local max_parallel_maintenance_workers=${PG_MAX_PARALLEL_MAINTENANCE_WORKERS:-$parallel_maint_workers}
|
||||
|
||||
local max_parallel_workers_per_gather=${PG_MAX_PARALLEL_WORKERS_PER_GATHER:-$workers_per_gather}
|
||||
|
||||
echo "max_worker_processes = $max_worker_processes"
|
||||
echo "max_parallel_workers_per_gather = $max_parallel_workers_per_gather"
|
||||
echo "max_parallel_workers = $max_parallel_workers"
|
||||
echo "max_parallel_maintenance_workers = $max_parallel_maintenance_workers"
|
||||
echo "$max_worker_processes $max_parallel_workers_per_gather $max_parallel_workers $max_parallel_maintenance_workers"
|
||||
}
|
||||
|
||||
# Calculate work_mem
|
||||
@@ -329,8 +336,10 @@ calc_work_mem() {
|
||||
|
||||
local shared_buffers_kb=$1
|
||||
local max_connections=$2
|
||||
local max_worker_processes=${PG_MAX_WORKER_PROCESSES:-8}
|
||||
|
||||
# the actual computed worker count, passed in by generate_env_vars so the divisor stays
|
||||
# consistent with the exported max_worker_processes (was previously assumed to be 8)
|
||||
local max_worker_processes=${3:-${PG_MAX_WORKER_PROCESSES:-8}}
|
||||
|
||||
local work_mem_kb=$(( (TOTAL_MEMORY_KB - shared_buffers_kb) / ((max_connections + max_worker_processes) * 3) ))
|
||||
|
||||
case "$PG_DB_TYPE" in
|
||||
@@ -339,9 +348,17 @@ calc_work_mem() {
|
||||
;;
|
||||
esac
|
||||
|
||||
# Minimum 64KB
|
||||
if [[ $work_mem_kb -lt 64 ]]; then
|
||||
work_mem_kb=64
|
||||
# Floor for web/oltp/mixed app workloads: below ~16MB, many-join queries (sorts + hashes)
|
||||
# constantly spill to disk-based algorithms writing temp files (measured multi-TB on a busy
|
||||
# instance at 16.6MB with an oversized max_connections divisor). Other profiles keep 64KB.
|
||||
local min_work_mem=64
|
||||
case "$PG_DB_TYPE" in
|
||||
"$DB_TYPE_WEB"|"$DB_TYPE_OLTP"|"$DB_TYPE_MIXED")
|
||||
min_work_mem=$((16 * MB / KB))
|
||||
;;
|
||||
esac
|
||||
if [[ $work_mem_kb -lt $min_work_mem ]]; then
|
||||
work_mem_kb=$min_work_mem
|
||||
fi
|
||||
|
||||
echo "$work_mem_kb"
|
||||
@@ -367,6 +384,48 @@ calc_checkpoint_completion_target() {
|
||||
echo "${PG_CHECKPOINT_COMPLETION_TARGET:-0.9}"
|
||||
}
|
||||
|
||||
# Calculate autovacuum_max_workers (~1/3 of cores, min 3 which is also the PG default)
|
||||
calc_autovacuum_max_workers() {
|
||||
if [[ -n "${PG_AUTOVACUUM_MAX_WORKERS:-}" ]]; then
|
||||
echo "$PG_AUTOVACUUM_MAX_WORKERS"
|
||||
return
|
||||
fi
|
||||
|
||||
local workers=$((CPU_COUNT / 3))
|
||||
if [[ $workers -lt 3 ]]; then
|
||||
workers=3
|
||||
fi
|
||||
echo "$workers"
|
||||
}
|
||||
|
||||
# WAL compression: lz4 is cheaper than the pglz default but needs PG >= 15
|
||||
calc_wal_compression() {
|
||||
if [[ -n "${PG_WAL_COMPRESSION:-}" ]]; then
|
||||
echo "$PG_WAL_COMPRESSION"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "${PG_DB_VERSION%%.*}" -ge 15 ]]; then
|
||||
echo "lz4"
|
||||
else
|
||||
echo "off"
|
||||
fi
|
||||
}
|
||||
|
||||
# TOAST compression for large values (post content etc.): lz4 needs PG >= 14
|
||||
calc_toast_compression() {
|
||||
if [[ -n "${PG_TOAST_COMPRESSION:-}" ]]; then
|
||||
echo "$PG_TOAST_COMPRESSION"
|
||||
return
|
||||
fi
|
||||
|
||||
if [[ "${PG_DB_VERSION%%.*}" -ge 14 ]]; then
|
||||
echo "lz4"
|
||||
else
|
||||
echo "pglz"
|
||||
fi
|
||||
}
|
||||
|
||||
# Main generation function - output as ENV vars
|
||||
generate_env_vars() {
|
||||
local max_connections shared_buffers_kb effective_cache_kb maint_work_mem_kb
|
||||
@@ -383,33 +442,20 @@ generate_env_vars() {
|
||||
default_stats_target=$(calc_default_statistics_target)
|
||||
random_page_cost=$(calc_random_page_cost)
|
||||
effective_io_concurrency=$(calc_effective_io_concurrency)
|
||||
work_mem_kb=$(calc_work_mem "$shared_buffers_kb" "$max_connections")
|
||||
huge_pages=$(calc_huge_pages)
|
||||
checkpoint_target=$(calc_checkpoint_completion_target)
|
||||
|
||||
# Calculate parallel settings as individual values
|
||||
# Parallel settings (single source: calc_parallel_settings), needed BEFORE work_mem
|
||||
# since the worker count is part of its divisor
|
||||
local max_worker_processes max_parallel_workers_per_gather max_parallel_workers max_parallel_maintenance_workers
|
||||
if [[ $CPU_COUNT -ge 4 ]]; then
|
||||
local workers_per_gather=$((CPU_COUNT / 2))
|
||||
if [[ "$PG_DB_TYPE" != "$DB_TYPE_DW" && $workers_per_gather -gt 4 ]]; then
|
||||
workers_per_gather=4
|
||||
fi
|
||||
|
||||
local parallel_maint_workers=$((CPU_COUNT / 2))
|
||||
if [[ $parallel_maint_workers -gt 4 ]]; then
|
||||
parallel_maint_workers=4
|
||||
fi
|
||||
read -r max_worker_processes max_parallel_workers_per_gather max_parallel_workers max_parallel_maintenance_workers <<< "$(calc_parallel_settings)"
|
||||
|
||||
max_worker_processes=${PG_MAX_WORKER_PROCESSES:-$CPU_COUNT}
|
||||
max_parallel_workers_per_gather=${PG_MAX_PARALLEL_WORKERS_PER_GATHER:-$workers_per_gather}
|
||||
max_parallel_workers=${PG_MAX_PARALLEL_WORKERS:-$CPU_COUNT}
|
||||
max_parallel_maintenance_workers=${PG_MAX_PARALLEL_MAINTENANCE_WORKERS:-$parallel_maint_workers}
|
||||
else
|
||||
max_worker_processes=${PG_MAX_WORKER_PROCESSES:-8}
|
||||
max_parallel_workers_per_gather=${PG_MAX_PARALLEL_WORKERS_PER_GATHER:-2}
|
||||
max_parallel_workers=${PG_MAX_PARALLEL_WORKERS:-8}
|
||||
max_parallel_maintenance_workers=${PG_MAX_PARALLEL_MAINTENANCE_WORKERS:-2}
|
||||
fi
|
||||
work_mem_kb=$(calc_work_mem "$shared_buffers_kb" "$max_connections" "$max_worker_processes")
|
||||
|
||||
local autovacuum_max_workers wal_compression toast_compression
|
||||
autovacuum_max_workers=$(calc_autovacuum_max_workers)
|
||||
wal_compression=$(calc_wal_compression)
|
||||
toast_compression=$(calc_toast_compression)
|
||||
|
||||
# Output ENV vars (only if not already set)
|
||||
cat << EOF
|
||||
@@ -431,6 +477,27 @@ export PG_MAX_WORKER_PROCESSES=\${PG_MAX_WORKER_PROCESSES:-$max_worker_processes
|
||||
export PG_MAX_PARALLEL_WORKERS_PER_GATHER=\${PG_MAX_PARALLEL_WORKERS_PER_GATHER:-$max_parallel_workers_per_gather}
|
||||
export PG_MAX_PARALLEL_WORKERS=\${PG_MAX_PARALLEL_WORKERS:-$max_parallel_workers}
|
||||
export PG_MAX_PARALLEL_MAINTENANCE_WORKERS=\${PG_MAX_PARALLEL_MAINTENANCE_WORKERS:-$max_parallel_maintenance_workers}
|
||||
# JIT: a per-execution LLVM compile tax on complex-but-fast app queries; off unless doing long analytics scans
|
||||
export PG_JIT=\${PG_JIT:-off}
|
||||
# observability: query stats extension (restart-required to change), I/O timing, full query texts in pg_stat_activity
|
||||
export PG_PRELOAD_LIBS=\${PG_PRELOAD_LIBS:-pg_stat_statements}
|
||||
export PG_TRACK_IO_TIMING=\${PG_TRACK_IO_TIMING:-on}
|
||||
export PG_TRACK_ACTIVITY_QUERY_SIZE=\${PG_TRACK_ACTIVITY_QUERY_SIZE:-16384}
|
||||
# autovacuum tuned for soft-delete/append app workloads (default 20% thresholds never trigger on big tables);
|
||||
# per-table thresholds for the hottest tables also ship as an app migration
|
||||
export PG_AUTOVACUUM_VACUUM_SCALE_FACTOR=\${PG_AUTOVACUUM_VACUUM_SCALE_FACTOR:-0.05}
|
||||
export PG_AUTOVACUUM_VACUUM_INSERT_SCALE_FACTOR=\${PG_AUTOVACUUM_VACUUM_INSERT_SCALE_FACTOR:-0.05}
|
||||
export PG_AUTOVACUUM_ANALYZE_SCALE_FACTOR=\${PG_AUTOVACUUM_ANALYZE_SCALE_FACTOR:-0.02}
|
||||
export PG_AUTOVACUUM_VACUUM_COST_LIMIT=\${PG_AUTOVACUUM_VACUUM_COST_LIMIT:-1000}
|
||||
export PG_AUTOVACUUM_MAX_WORKERS=\${PG_AUTOVACUUM_MAX_WORKERS:-$autovacuum_max_workers}
|
||||
export PG_LOG_AUTOVACUUM_MIN_DURATION=\${PG_LOG_AUTOVACUUM_MIN_DURATION:-0}
|
||||
# cheaper compression codecs (version-gated: wal lz4 needs PG15+, toast lz4 PG14+)
|
||||
export PG_WAL_COMPRESSION=\${PG_WAL_COMPRESSION:-$wal_compression}
|
||||
export PG_TOAST_COMPRESSION=\${PG_TOAST_COMPRESSION:-$toast_compression}
|
||||
# diagnostics logging: slow statements (server-side; the app logs its own from 100ms), lock waits, temp-file spills
|
||||
export PG_LOG_MIN_DURATION_STATEMENT=\${PG_LOG_MIN_DURATION_STATEMENT:-2000}
|
||||
export PG_LOG_LOCK_WAITS=\${PG_LOG_LOCK_WAITS:-on}
|
||||
export PG_LOG_TEMP_FILES=\${PG_LOG_TEMP_FILES:-0}
|
||||
EOF
|
||||
}
|
||||
|
||||
|
||||
@@ -224,6 +224,7 @@ wal_buffers = ${PG_WAL_BUFFERS_MB}MB # min 32kB, -1 sets based on shared_buffers
|
||||
#full_page_writes = on # recover from partial page writes
|
||||
#wal_log_hints = off # also do full page writes of non-critical updates
|
||||
# (change requires restart)
|
||||
wal_compression = ${PG_WAL_COMPRESSION} # cheaper full-page writes (lz4 on PG15+; computed by postgres-tune.sh)
|
||||
#wal_compression = off # enables compression of full-page writes;
|
||||
# off, pglz, lz4, zstd, or on
|
||||
#wal_init_zero = on # zero-fill new WAL files
|
||||
@@ -430,6 +431,7 @@ default_statistics_target = ${PG_DEFAULT_STATISTICS_TARGET} # range 1-10000
|
||||
#constraint_exclusion = partition # on, off, or partition
|
||||
#cursor_tuple_fraction = 0.1 # range 0.0-1.0
|
||||
#from_collapse_limit = 8
|
||||
jit = ${PG_JIT} # per-execution LLVM compile tax on complex-but-fast app queries; off by default (tune with PG_JIT)
|
||||
#jit = on # allow JIT compilation
|
||||
#join_collapse_limit = 8 # 1 disables collapsing of explicit
|
||||
# JOIN clauses
|
||||
@@ -517,6 +519,7 @@ default_statistics_target = ${PG_DEFAULT_STATISTICS_TARGET} # range 1-10000
|
||||
# fatal
|
||||
# panic (effectively off)
|
||||
|
||||
log_min_duration_statement = ${PG_LOG_MIN_DURATION_STATEMENT} # server-side slow-statement log (the app logs its own from 100ms)
|
||||
#log_min_duration_statement = -1 # -1 is disabled, 0 logs all statements
|
||||
# and their durations, > 0 logs only
|
||||
# statements running at least this number
|
||||
@@ -548,6 +551,7 @@ default_statistics_target = ${PG_DEFAULT_STATISTICS_TARGET} # range 1-10000
|
||||
#debug_print_rewritten = off
|
||||
#debug_print_plan = off
|
||||
#debug_pretty_print = on
|
||||
log_autovacuum_min_duration = ${PG_LOG_AUTOVACUUM_MIN_DURATION} # log every autovacuum run — the regression tripwire for autovacuum-never-runs
|
||||
#log_autovacuum_min_duration = 10min # log autovacuum activity;
|
||||
# -1 disables, 0 logs all actions and
|
||||
# their durations, > 0 logs only
|
||||
@@ -583,6 +587,7 @@ default_statistics_target = ${PG_DEFAULT_STATISTICS_TARGET} # range 1-10000
|
||||
# processes
|
||||
# %% = '%'
|
||||
# e.g. '<%u%%%d> '
|
||||
log_lock_waits = ${PG_LOG_LOCK_WAITS}
|
||||
#log_lock_waits = off # log lock waits >= deadlock_timeout
|
||||
#log_recovery_conflict_waits = off # log standby recovery conflict waits
|
||||
# >= deadlock_timeout
|
||||
@@ -594,6 +599,7 @@ default_statistics_target = ${PG_DEFAULT_STATISTICS_TARGET} # range 1-10000
|
||||
# -1 means print in full, 0 disables
|
||||
#log_statement = 'none' # none, ddl, mod, all
|
||||
#log_replication_commands = off
|
||||
log_temp_files = ${PG_LOG_TEMP_FILES} # log all temp-file spills (the work_mem-too-small signal)
|
||||
#log_temp_files = -1 # log temporary files equal or larger
|
||||
# than the specified size in kilobytes;
|
||||
# -1 disables, 0 logs all temp files
|
||||
@@ -613,8 +619,10 @@ default_statistics_target = ${PG_DEFAULT_STATISTICS_TARGET} # range 1-10000
|
||||
# - Cumulative Query and Index Statistics -
|
||||
|
||||
#track_activities = on
|
||||
track_activity_query_size = ${PG_TRACK_ACTIVITY_QUERY_SIZE} # full query texts in pg_stat_activity (change requires restart)
|
||||
#track_activity_query_size = 1024 # (change requires restart)
|
||||
#track_counts = on
|
||||
track_io_timing = ${PG_TRACK_IO_TIMING} # needed for pg_stat_statements I/O attribution
|
||||
#track_io_timing = off
|
||||
#track_wal_io_timing = off
|
||||
#track_functions = none # none, pl, all
|
||||
@@ -636,6 +644,7 @@ default_statistics_target = ${PG_DEFAULT_STATISTICS_TARGET} # range 1-10000
|
||||
|
||||
#autovacuum = on # Enable autovacuum subprocess? 'on'
|
||||
# requires track_counts to also be on.
|
||||
autovacuum_max_workers = ${PG_AUTOVACUUM_MAX_WORKERS} # (change requires restart)
|
||||
#autovacuum_max_workers = 3 # max number of autovacuum subprocesses
|
||||
# (change requires restart)
|
||||
#autovacuum_naptime = 1min # time between autovacuum runs
|
||||
@@ -646,9 +655,12 @@ default_statistics_target = ${PG_DEFAULT_STATISTICS_TARGET} # range 1-10000
|
||||
# vacuums
|
||||
#autovacuum_analyze_threshold = 50 # min number of row updates before
|
||||
# analyze
|
||||
autovacuum_vacuum_scale_factor = ${PG_AUTOVACUUM_VACUUM_SCALE_FACTOR} # default 0.2 never triggers on big tables
|
||||
#autovacuum_vacuum_scale_factor = 0.2 # fraction of table size before vacuum
|
||||
autovacuum_vacuum_insert_scale_factor = ${PG_AUTOVACUUM_VACUUM_INSERT_SCALE_FACTOR} # key for append-mostly workloads: keeps visibility maps fresh for index-only scans
|
||||
#autovacuum_vacuum_insert_scale_factor = 0.2 # fraction of inserts over table
|
||||
# size before insert vacuum
|
||||
autovacuum_analyze_scale_factor = ${PG_AUTOVACUUM_ANALYZE_SCALE_FACTOR}
|
||||
#autovacuum_analyze_scale_factor = 0.1 # fraction of table size before analyze
|
||||
#autovacuum_freeze_max_age = 200000000 # maximum XID age before forced vacuum
|
||||
# (change requires restart)
|
||||
@@ -658,6 +670,7 @@ default_statistics_target = ${PG_DEFAULT_STATISTICS_TARGET} # range 1-10000
|
||||
#autovacuum_vacuum_cost_delay = 2ms # default vacuum cost delay for
|
||||
# autovacuum, in milliseconds;
|
||||
# -1 means use vacuum_cost_delay
|
||||
autovacuum_vacuum_cost_limit = ${PG_AUTOVACUUM_VACUUM_COST_LIMIT} # default (200 via vacuum_cost_limit) is glacial on multi-GB tables
|
||||
#autovacuum_vacuum_cost_limit = -1 # default vacuum cost limit for
|
||||
# autovacuum, -1 means use
|
||||
# vacuum_cost_limit
|
||||
@@ -683,6 +696,7 @@ default_statistics_target = ${PG_DEFAULT_STATISTICS_TARGET} # range 1-10000
|
||||
#row_security = on
|
||||
#default_table_access_method = 'heap'
|
||||
#default_tablespace = '' # a tablespace name, '' uses the default
|
||||
default_toast_compression = ${PG_TOAST_COMPRESSION} # lz4 on PG14+ (computed by postgres-tune.sh)
|
||||
#default_toast_compression = 'pglz' # 'pglz' or 'lz4'
|
||||
#temp_tablespaces = '' # a list of tablespace names, '' uses
|
||||
# only default tablespace
|
||||
@@ -741,6 +755,7 @@ default_statistics_target = ${PG_DEFAULT_STATISTICS_TARGET} # range 1-10000
|
||||
|
||||
#local_preload_libraries = ''
|
||||
#session_preload_libraries = ''
|
||||
shared_preload_libraries = '${PG_PRELOAD_LIBS}' # pg_stat_statements etc. (change requires restart)
|
||||
#shared_preload_libraries = '' # (change requires restart)
|
||||
#jit_provider = 'llvmjit' # JIT library to use
|
||||
|
||||
@@ -817,3 +832,4 @@ default_statistics_target = ${PG_DEFAULT_STATISTICS_TARGET} # range 1-10000
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Add settings for extensions here
|
||||
pg_stat_statements.track = all
|
||||
|
||||
Reference in New Issue
Block a user