-
Notifications
You must be signed in to change notification settings - Fork 3
/
config.py
128 lines (94 loc) · 4.17 KB
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# -*- coding: UTF-8 -*-
import tornado.web
import json
from common import util, bytes, ParameterFormat
def config_hard_disk(drive_type, define_doc):
category = {}
# Hard Drive Configuration
category = {}
category["category"] = "storage_type"
category["description"] = "Storage Configuration"
category["parameters"] = list()
# random_page_cost
parameter = {}
parameter["name"] = "random_page_cost"
parameter["format"] = ParameterFormat.Float
abstract = "Sets the planner's estimate of the cost of a \
non-sequentially-fetched disk page."
default_value = "4.0"
recomendation_posts = {}
recomendation_posts[
"How a single PostgreSQL config change improved slow query performance by 50x"] = "https://amplitude.engineering/how-a-single-postgresql-config-change-improved-slow-query-performance-by-50x-85593b8991b0"
parameter["documentation"] = define_doc(
parameter["name"],
"runtime-config-query.html#GUC-RANDOM-PAGE-COST", abstract,
default_value, recomendation_posts)
values = {"HDD": 4.0, "SSD": 1.1, "SAN": 1.1}
parameter["formula"] = values[drive_type]
category["parameters"].append(parameter)
# effective_io_concurrency
parameter = {}
parameter["name"] = "effective_io_concurrency"
parameter["format"] = ParameterFormat.Decimal
abstract = "Sets the number of concurrent disk I/O operations that \
PostgreSQL expects can be executed simultaneously."
default_value = "1"
recomendation_posts = {}
recomendation_posts[
"PostgreSQL: effective_io_concurrency benchmarked"] = "https://portavita.github.io/2019-07-19-PostgreSQL_effective_io_concurrency_benchmarked/"
parameter["documentation"] = define_doc(
parameter["name"],
"runtime-config-resource.html#GUC-EFFECTIVE-IO-CONCURRENCY",
abstract, default_value, recomendation_posts)
values = {"HDD": 2, "SSD": 200, "SAN": 300}
parameter["formula"] = values[drive_type]
category["parameters"].append(parameter)
return category
def config_worker_process(pg_version, cpus, define_doc):
category = {}
if cpus < 0:
return category
# Worker Processes
if float(pg_version) >= 9.5:
category["category"] = "worker_processes"
category["description"] = "Worker Processes"
category["parameters"] = list()
parameter = {}
parameter["name"] = "max_worker_processes"
parameter["format"] = ParameterFormat.Decimal
abstract = "Sets the maximum number of background processes that \
the system can support."
default_value = 8 if float(pg_version) >= 9.6 else 1
parameter["documentation"] = define_doc(
parameter["name"],
"runtime-config-resource.html#GUC-MAX-WORKER-PROCESSES",
abstract, default_value)
parameter["formula"] = cpus
category["parameters"].append(parameter)
if float(pg_version) >= 9.6:
parameter = {}
parameter["name"] = "max_parallel_workers_per_gather"
parameter["format"] = ParameterFormat.Decimal
abstract = "Sets the maximum number of workers that can be \
started by a single Gather node."
default_value = 2
parameter["documentation"] = define_doc(
parameter["name"],
"runtime-config-resource.html#GUC-MAX-PARALLEL-WORKERS-PER-GATHER",
abstract, default_value)
parameter["formula"] = "(CPUS/2)" if cpus > 1 else default_value
category["parameters"].append(parameter)
if float(pg_version) >= 10:
parameter = {}
parameter["name"] = "max_parallel_workers"
parameter["format"] = ParameterFormat.Decimal
abstract = "Sets the maximum number of workers that the system \
can support for parallel queries."
default_value = 8
parameter["documentation"] = define_doc(
parameter["name"],
"runtime-config-resource.html#GUC-MAX-PARALLEL-WORKERS",
abstract, default_value)
parameter["formula"] = cpus
category["parameters"].append(parameter)
return category