Projekt

Allgemein

Profil

710 Datenbankeinstellungen und Tuning (postgresql conf) » Historie » Version 78

[X] Daniel S, 01.02.2023 23:49

1 74 [S] Dominik G
h1. Datenbankeinstellungen und Tuning (postgresql.conf)
2 1 [X] Daniel S
3 26 [S] Philipp K
4 23 [E] Oleg G
@postgresql.conf@ ([[PostgreSQL Netzwerkkonfiguration (pg_hba.conf)]])
5 1 [X] Daniel S
6 56 [S] Dominik G
Datei-Pfad: *..\PostgreSQL\9.6\data\pg96\postgresql.conf*
7 25 [E] Oleg G
8 58 [S] Philipp K
h2. Prüfen der wichtigsten Postgreseinstellungen mittels Datenbankfunktion
9
10 65 [E] Frank S
Die Funktionen heißen @TSystem.database_settings__initialize()@ und @TSystem.database_settings__validate()@ und muss bei Neuerungen entsprechend angepasst oder erweitert werden.
11 54 [S] Philipp K
12 1 [X] Daniel S
h2. Konfiguration PostgreSQL (Beachte Betriebssystem) ab Version 9.3 
13 54 [S] Philipp K
14 51 [X] Daniel S
Beachte Programm-Start-Prüfung PRODAT: #9933
15 60 [S] Philipp K
Für ein 16GB RAM System
16 1 [X] Daniel S
17 69 [X] Richard H
|_.° |_. param                |_. value    |_. Bemerkung |
18 77 [X] Daniel S
|   | shared_buffers         | 4096MB     | Daumenregel: ca 1/4 Des RAMs den Rest für effective_cache_size. Große Datenbanken mehr! https://distributedsystemsauthority.com/optimizing-postgresql-shared-buffers/ |
19 69 [X] Richard H
|   | temp_buffers           | 8MB        ||
20 78 [X] Daniel S
|   | work_mem | 128MB| nicht zu hoch, da je sort bzw. hash Operation, auch mehrfach bei komplexen queries » https://www.citusdata.com/blog/2018/06/12/configuring-work-mem-on-postgres/ |
21 69 [X] Richard H
|   | maintenance_work_mem       | 512MB | für VACUUM, CREATE INDEX, and ALTER TABLE ADD FOREIGN KEY, außerdem für restore dumps |
22
|   | dynamic_shared_memory_type | windows ||
23
|   | max_worker_processes | 8 | Default ist 8 (keine Änderung nötig). Je nach Unternehmensgröße mehr |
24
| ° | max_parallel_workers_per_gather | 4 ||
25 75 [X] Richard H
|   | fsync| on ||
26 69 [X] Richard H
|   | synchronous_commit| off ||
27
|   | wal_compression| on || 
28
|   | wal_buffers| -1 |   (bis 9.3 8MB) |
29
|   | max_wal_size| 3GB |     (ab 9.6 Ersatz für checkpoint_segments3 * checkpoint_segments) * 16MB )|
30 72 [X] Richard H
| ° | max_locks_per_transaction | 1024 | https://redmine.prodat-sql.de/issues/12311 |
31 69 [X] Richard H
|   | effective_cache_size | 12288MB | Beachte, wenn Server nur für PRODAT dann 3/4 des Arbeitsspeichers, wenn auch andere Programme dort laufen dann 1/2 Arbeitsspeicher. Gibt an wieviel RAM-Cache Postgressql erwarten kann, für Indizies usw |
32
|   | default_statistics_target | 1000 ||
33
| ° | seq_page_cost | 2.0 | Mache sequentielle Scans "teurer": Der Planer ist eher geneigt, den Index zu nutzen |
34 76 [S] Dominik G
| ° | random_page_cost | 4.0 | ssds vs hdds |
35 69 [X] Richard H
| ° | cursor_tuple_fraction | 0.75 | (siehe #6436) (Steuert, dass das CURSOR-FETCH (F2-Fenster) anders errechnet wird und es Blöcke früher zurückgibt) |
36
|   | log_destination | 'eventlog' | (unter Windows) |
37 1 [X] Daniel S
|   | log_checkpoints | off | auf Default setzen |
38 77 [X] Daniel S
|   | checkpoint_timeout |30min | https://www.2ndquadrant.com/en/blog/basics-of-tuning-checkpoints/ |
39
|   | max_wal_size | 10GB | https://www.2ndquadrant.com/en/blog/basics-of-tuning-checkpoints/ https://www.2ndquadrant.com/en/blog/tpc-h-performance-since-postgresql-8-3/ |
40 1 [X] Daniel S
|   | log_line_prefix | '<%u@@@%d-%t> ' ||
41 77 [X] Daniel S
|   | vacuum_cost_limit | 2000 | https://www.2ndquadrant.com/en/blog/autovacuum-tuning-basics/ |
42 73 [X] Richard H
| ° | log_autovacuum_min_duration | 3s | # default -1@ (auf Default setzen) > alles was länger 3s dauert loggen und bei Gelegnheit prüfen|
43 69 [X] Richard H
|   | search_path | '"$user",public,TSystem,prodat_languages,Z_99_Deprecated' ||
44
|   | datestyle | 'iso, dmy' ||
45
|   | standard_conforming_strings | off | siehe #4860 |
46
|   | lc_messages | 'en_US.UTF-8' | (Das muß sein, da wir die Fehlermeldungen teilweise parsen und somit auf die Fehler-Strings gehen.) |
47
|   | lc_monetary | 'German_Germany.1252' | (Lokale je nach Land) |
48
|   | lc_numeric | 'German_Germany.1252' | |
49
|   | lc_time | 'German_Germany.1252' | |
50 56 [S] Dominik G
51
{{collapse(Alte Versionen:)
52 1 [X] Daniel S
@checkpoint_segments = 64 # in 9.6 nicht supported@
53 66 [E] Frank S
° @statement_timeout = 120000@ Bis Prodat 11.5.3@ wird clientseitig im Prodat gesetzt (480000 und für AppServer/Admins 1200000)
54 49 [S] Philipp K
}}
55 66 [E] Frank S
56 67 [E] Frank S
!!! ° = *Für einige Werte gibt es Vorgaben und Prüfungen, in den Client-Sessions.*
57 66 [E] Frank S
!!! siehe @TSystem.database_settings__initialize@ und @TSystem.database_settings__validate@ (PSQL\0050 System\010 Functions TSystem.sql)
58 1 [X] Daniel S
59 57 [S] Dominik G
h2. Reload
60
61
Konfiguration im laufenden Betrieb neu laden.
62
@..\PostgreSQL\pg96\bin\pg_ctl reload -D ..\PostgreSQL\data\pg96@
63
64 34 [X] Daniel S
65
h2. Linux 
66
67
{{collapse(Linux)
68
69
h3. Betriebssystem - Speichereinstellungen mind. 3GiB Arbeitsspeicher!
70
71
* standard:
72
sysctl kernel.shmmax
73
kernel.shmmax = 33554432
74
75
* umsetzen auf 280437720 (256MB, Mindestens, LOLL steht auf 1024MB (8GB Ram)) (On Windows the useful range is 64MB to 512MB)
76
/etc/sysctl.conf  -> zeile aufnehmen: kernel.shmmax=280437720
77
reboot
78
79
h3. Nur auf Systemen mit 3GiB+ RAM anzuwenden
80
81
@$ free -m@
82
<pre>
83
             total       used       free     shared    buffers     cached
84
Mem:          3018       1516       1501          0        208       1113
85
-/+ buffers/cache:        194       2823
86
Swap:         1023          0       1023
87
</pre>
88
89
90
h3. Weiteres
91
92
Unter Linux ist noch die shmmax-Option aus der 99-postgresql.conf via sysctl zu setzen, sonst klappert das da.
93
http://www.postgresql.org/docs/8.2/static/kernel-resources.html
94
95
}}
96 1 [X] Daniel S
97 19 [S] Dominik G
98 14 [S] Dominik G
Könnte durchaus noch weiter getrieben werden, indem man Sie auf die Prodat-DB abstimmt:
99 13 [S] Dominik G
* http://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server
100 11 [X] Daniel S
* http://www.postgresql.org/docs/current/static/performance-tips.html
101 13 [S] Dominik G
* "five_steps_perform_2009.pdf":http://www.prodat-sql.de/redmine/attachments/download/2528/five_steps_perform_2009.pdf Dokument über Einstellungen etc
102
103 19 [S] Dominik G
104
*Hinweis:* Fehler im PgAdmin/Server-Status: ungültige Byte-Sequenz für Kodierung "UTF8" ... durch SELECT pg_file_read('pg_log/... kann ignoriert werden, da wir ja ins eventlog schreiben.
105
Die Anzeige vom Log hier einfach schließen. Liegt an LC_MESSAGES und mehrsprachigen Systemen, vermutlich ein Bug, Workaround LC_MESSAGES='C' (evtl. nicht mit Prodat kompatibel)
106 11 [X] Daniel S
107 12 [X] Daniel S
108 13 [S] Dominik G
h2. Virtualisierung
109 12 [X] Daniel S
110 13 [S] Dominik G
"Database_Virtualization_PG_China.pdf":http://www.prodat-sql.de/redmine/attachments/download/2568/Database_Virtualization_PG_China.pdf