mirror of
https://abf.rosa.ru/djam/postgrespro-1c.git
synced 2025-02-23 21:42:47 +00:00
68 lines
2.1 KiB
Bash
Executable file
68 lines
2.1 KiB
Bash
Executable file
#!/bin/sh
|
|
# This script generates set of configuration options
|
|
# tuned for 1C database
|
|
|
|
limit() {
|
|
## This function checks if first arg is within limits set by second
|
|
## and third arg. If so, it prints out first arg, otherwise - limit
|
|
## minimal limit should always be specified. maximal can be omitted
|
|
## and would be considered infinity
|
|
computed="$1"
|
|
min="$2"
|
|
max="$3"
|
|
if [ "$computed" -lt "$min" ]; then
|
|
echo "$min"
|
|
elif [ -n "$max" ] && [ "$computed" -gt "$max" ]; then
|
|
echo "$max"
|
|
else
|
|
echo "$computed"
|
|
fi
|
|
}
|
|
|
|
if [ "$1" != "--nocheck" ]; then
|
|
PREFIX=$(dirname $(dirname $0))
|
|
EDVER=$(basename $PREFIX)
|
|
for module in plantuner online_analyze; do
|
|
if [ ! -e ${PREFIX}/lib/${module}.so ]; then
|
|
echo "Module $module is not found. Please install postgrespro-${EDVER}-contrib package" 1>&2
|
|
exit 1
|
|
fi
|
|
done
|
|
fi
|
|
# Number of CPUS
|
|
NCPU=$(nproc)
|
|
# Size of RAM in megabytes
|
|
RAMMB=$(LC_MESSAGES=C free -m|awk '/Mem:/ {print $2;}')
|
|
# This is set of options to be added to config
|
|
|
|
cat << END_OF_CONF
|
|
listen_addresses = '*'
|
|
shared_buffers = $((RAMMB/4))MB # 25% of RAM
|
|
temp_buffers = 128MB
|
|
max_files_per_process = 10000
|
|
max_parallel_workers_per_gather = 0
|
|
max_parallel_maintenance_workers = $(limit $((NCPU/4)) 2 6) # Количество CPU/4, минимум 2, максимум 6
|
|
commit_delay = 1000
|
|
max_wal_size = 4GB
|
|
min_wal_size = 2GB
|
|
checkpoint_timeout = 15min
|
|
effective_cache_size = $((RAMMB*3/4))MB # 75% of RAM
|
|
from_collapse_limit = 8
|
|
join_collapse_limit = 8
|
|
autovacuum_max_workers = $(limit $((NCPU/2)) 2) # Количество CPU/2, минимум 2
|
|
vacuum_cost_limit = $(limit $((NCPU*50)) 200) # 100* autovacuum_max_workers
|
|
autovacuum_naptime = 20s
|
|
autovacuum_vacuum_scale_factor = 0.01
|
|
autovacuum_analyze_scale_factor = 0.005
|
|
max_locks_per_transaction = 256
|
|
escape_string_warning = off
|
|
standard_conforming_strings = off
|
|
shared_preload_libraries = 'online_analyze, plantuner'
|
|
online_analyze.threshold = 50
|
|
online_analyze.scale_factor = 0.1
|
|
online_analyze.enable = on
|
|
online_analyze.verbose = off
|
|
online_analyze.min_interval = 10000
|
|
online_analyze.table_type = 'temporary'
|
|
plantuner.fix_empty_table = on
|
|
END_OF_CONF
|