You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: enhance parameter docs with structured alerts
Improve readability and highlight critical information using
GitHub-style alert blocks (NOTE, TIP, WARNING, IMPORTANT). Convert
formulas to code blocks, add backticks to parameters/commands, and
reorganize recommendations for better discoverability.
Makes warnings about OOM risks, Windows limits, and security
practices more prominent and scannable.
Signed-off-by: Sebastian Webber <sebastian@swebber.me>
Allocates shared memory for caching data pages. Acts as PostgreSQL's main disk cache, similar to Oracle's SGA buffer.
6
6
7
-
Start with **25% of RAM** as a baseline. For optimal tuning, use the **pg_buffercache extension** to analyze cache hit ratios for your specific workload.
7
+
Start with **25% of RAM** as a baseline. For optimal tuning, use the `pg_buffercache` extension to analyze cache hit ratios for your specific workload.
8
8
recomendations:
9
9
Tuning Your PostgreSQL Server: https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server#shared_buffers
10
10
Determining optimal shared_buffers using pg_buffercache: https://aws.amazon.com/blogs/database/determining-the-optimal-value-for-shared_buffers-using-the-pg_buffercache-extension-in-postgresql/
@@ -27,17 +27,28 @@ categories:
27
27
Optimize PostgreSQL Server Performance Through Configuration: https://blog.crunchydata.com/blog/optimize-postgresql-server-performance
28
28
work_mem:
29
29
abstract: |
30
-
Memory per operation for sorts, hash joins, and aggregates. Each query can use **multiple work_mem buffers** simultaneously.
31
-
32
-
**⚠️ Warning**: With high concurrency and large datasets, you can easily trigger **OOM kills** in Kubernetes pods or cloud instances.
**Windows ≤ PostgreSQL 17**: Maximum value is ~2GB (2097151 kB) due to Windows LLP64 model where `sizeof(long)==4` even on 64-bit systems. Fixed in [PostgreSQL 18](https://www.postgresql.org/message-id/flat/1a01f0-66ec2d80-3b-68487680@27595217) which increased the limit to 2TB. See also [pgvector issue #667](https://github.com/pgvector/pgvector/issues/667).
39
-
40
-
Monitor temp file usage with `log_temp_files`. Consider **per-session** tuning (`SET work_mem`) for heavy queries instead of global settings.
30
+
Memory per operation for sorts, hash joins, and aggregates. Each query can use multiple `work_mem` buffers simultaneously.
31
+
32
+
> [!WARNING]
33
+
> With high concurrency and large datasets, you can easily trigger **OOM kills** in Kubernetes pods or cloud instances.
34
+
>
35
+
> Maximum potential memory:
36
+
> ```
37
+
> max = work_mem × operations × parallel_workers × connections
> **Windows ≤ PostgreSQL 17**: Maximum value is ~2GB (2097151 kB) due to Windows LLP64 model where `sizeof(long)==4` even on 64-bit systems.
47
+
>
48
+
> Fixed in [PostgreSQL 18](https://www.postgresql.org/message-id/flat/1a01f0-66ec2d80-3b-68487680@27595217) which increased the limit to 2TB. See also [pgvector issue #667](https://github.com/pgvector/pgvector/issues/667).
49
+
50
+
> [!TIP]
51
+
> Monitor temp file usage with `log_temp_files`. Consider **per-session** tuning (`SET work_mem`) for heavy queries instead of global settings.
41
52
details:
42
53
- Specifies the amount of memory to be used by internal sort operations and hash tables before writing to temporary disk files. The value defaults to four megabytes (4MB). Note that for a complex query, several sort or hash operations might be running in parallel; each operation will be allowed to use as much memory as this value specifies before it starts to write data into temporary files. Also, several running sessions could be doing such operations concurrently. Therefore, the total memory used could be many times the value of work_mem; it is necessary to keep this fact in mind when choosing the value. Sort operations are used for ORDER BY, DISTINCT, and merge joins. Hash tables are used in hash joins, hash-based aggregation, and hash-based processing of IN subqueries.
43
54
recomendations:
@@ -49,15 +60,22 @@ categories:
49
60
Let's get back to basics - PostgreSQL Memory Components: https://www.postgresql.fastware.com/blog/back-to-basics-with-postgresql-memory-components
50
61
maintenance_work_mem:
51
62
abstract: |
52
-
Memory for maintenance operations: **VACUUM**, **CREATE INDEX**, **ALTER TABLE**, and autovacuum workers.
53
-
54
-
Can be set higher than work_mem since fewer concurrent maintenance operations run.
55
-
56
-
**Important**: Total usage = `maintenance_work_mem × autovacuum_max_workers`. Consider using `autovacuum_work_mem` separately.
57
-
58
-
**PostgreSQL ≤16**: 1GB limit (~179M dead tuples per pass). **PostgreSQL 17+**: No limit (uses radix trees).
59
-
60
-
**Windows ≤ PostgreSQL 17**: Maximum value is ~2GB (2097151 kB) due to Windows LLP64 model where `sizeof(long)==4` even on 64-bit systems. Fixed in [PostgreSQL 18](https://www.postgresql.org/message-id/flat/1a01f0-66ec2d80-3b-68487680@27595217) which increased the limit to 2TB. See also [pgvector issue #667](https://github.com/pgvector/pgvector/issues/667).
63
+
Memory for maintenance operations: `VACUUM`, `CREATE INDEX`, `ALTER TABLE`, and autovacuum workers.
64
+
65
+
Can be set higher than `work_mem` since fewer concurrent maintenance operations run.
66
+
67
+
> [!IMPORTANT]
68
+
> Total usage:
69
+
> ```
70
+
> total = maintenance_work_mem × autovacuum_max_workers
71
+
> ```
72
+
>
73
+
> Consider using `autovacuum_work_mem` separately.
74
+
75
+
> [!NOTE]
76
+
> **PostgreSQL ≤16**: 1GB limit (~179M dead tuples per pass). **PostgreSQL 17+**: No limit (uses radix trees).
77
+
>
78
+
> **Windows ≤ PostgreSQL 17**: Maximum value is ~2GB (2097151 kB) due to Windows LLP64 model where `sizeof(long)==4` even on 64-bit systems. Fixed in [PostgreSQL 18](https://www.postgresql.org/message-id/flat/1a01f0-66ec2d80-3b-68487680@27595217) which increased the limit to 2TB. See also [pgvector issue #667](https://github.com/pgvector/pgvector/issues/667).
"Tuning max_connections in PostgreSQL": https://www.cybertec-postgresql.com/en/tuning-max_connections-in-postgresql/
148
186
"Why you should use Connection Pooling": https://www.enterprisedb.com/postgres-tutorials/why-you-should-use-connection-pooling-when-setting-maxconnections-postgres
@@ -156,13 +194,16 @@ categories:
156
194
157
195
Lower values favor index scans, higher values favor sequential scans. Sequential scans become more efficient when queries return ~5-10% or more of table rows, common in analytical/DW workloads.
158
196
159
-
**Debate (2025)**: Some experts advocate keeping higher values (4.0) for **plan stability** across cache states, while others recommend lower values (1.1-2.0) for SSD to favor index scans.
197
+
> [!NOTE]
198
+
> **Ongoing debate (2025)**: Some experts advocate keeping higher values (4.0) for **plan stability** across cache states, while others recommend lower values (1.1-2.0) for SSD to favor index scans.
199
+
>
200
+
> Check suggested readings #1 and #2 for detailed analysis.
160
201
161
202
Test with `EXPLAIN ANALYZE` to verify query plan choices for your workload.
162
203
recomendations:
163
-
"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
164
-
"Better PostgreSQL performance on SSDs": https://www.cybertec-postgresql.com/en/better-postgresql-performance-on-ssds/
165
204
"PostgreSQL with modern storage: what about a lower random_page_cost?": https://dev.to/aws-heroes/postgresql-with-modern-storage-what-about-a-lower-randompagecost-5b7f
205
+
"Better PostgreSQL performance on SSDs": https://www.cybertec-postgresql.com/en/better-postgresql-performance-on-ssds/
206
+
"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
166
207
"Postgres Scan Types in EXPLAIN Plans": https://www.crunchydata.com/blog/postgres-scan-types-in-explain-plans
167
208
"Tuning Your PostgreSQL Server": https://wiki.postgresql.org/wiki/Tuning_Your_PostgreSQL_Server
168
209
effective_io_concurrency:
@@ -171,22 +212,22 @@ categories:
171
212
172
213
Bitmap scans are used when queries need to fetch moderate result sets (too many rows for index scans, too few for sequential scans) or when combining multiple indexes. They're more common in analytical workloads.
173
214
174
-
PostgreSQL 18 changes the default from 1 to 16. Values above 200 show diminishing returns in benchmarks.
215
+
> [!NOTE]
216
+
> **PostgreSQL 18** changes the default from `1` to `16`. Values above `200` show diminishing returns in benchmarks.
"PostgreSQL indexing: Index scan vs. Bitmap scan vs. Sequential scan (basics)": https://www.cybertec-postgresql.com/en/postgresql-indexing-index-scan-vs-bitmap-scan-vs-sequential-scan-basics/
179
221
io_method:
180
222
abstract: |
181
-
Selects the async I/O implementation for read operations (PostgreSQL 18+).
182
-
183
-
**worker** (default): Uses dedicated background processes. Best for most workloads, especially high-bandwidth sequential scans. Recommended as default.
184
-
185
-
**io_uring** (Linux only): Kernel-level async I/O. Only switch after extensive testing proves benefit for your specific low-latency random-read patterns. Can hit file descriptor limits with high max_connections.
223
+
Selects the async I/O implementation for read operations (PostgreSQL 18+):
186
224
187
-
**sync**: Traditional synchronous I/O. Slower than async methods - avoid unless debugging or testing.
225
+
- **`worker`** (default): Uses dedicated background processes. Best for most workloads, especially high-bandwidth sequential scans. Recommended as default.
226
+
- **`io_uring`** (Linux only): Kernel-level async I/O. Only switch after extensive testing proves benefit for your specific low-latency random-read patterns. Can hit file descriptor limits with high `max_connections`.
227
+
- **`sync`**: Traditional synchronous I/O. Slower than async methods - avoid unless debugging or testing.
188
228
189
-
Note: Only affects reads. Writes, checkpoints, and WAL still use sync I/O.
229
+
> [!NOTE]
230
+
> Only affects reads. Writes, checkpoints, and WAL still use sync I/O.
190
231
recomendations:
191
232
"Tuning AIO in PostgreSQL 18 - Tomas Vondra": https://vondra.me/posts/tuning-aio-in-postgresql-18/
192
233
"Waiting for Postgres 18: Accelerating Disk Reads with Asynchronous I/O - pganalyze": https://pganalyze.com/blog/postgres-18-async-io
@@ -197,7 +238,10 @@ categories:
197
238
abstract: |
198
239
Background worker processes for async I/O when `io_method = worker`.
199
240
200
-
Default of 3 is too low for modern multi-core systems. Recommendation: **10-40% of CPU cores** depending on workload.
241
+
> [!TIP]
242
+
> Default of `3` is too low for modern multi-core systems.
243
+
>
244
+
> **Recommendation**: 10-40% of CPU cores depending on workload.
201
245
202
246
Higher values benefit workloads with:
203
247
- Sequential scans (DW/analytical queries)
@@ -247,7 +291,10 @@ categories:
247
291
abstract: |
248
292
Hard limit on concurrent I/O operations per backend process (PostgreSQL 18+).
Method for copying files during **CREATE DATABASE** and **ALTER DATABASE SET TABLESPACE** (PostgreSQL 18+).
308
+
Method for copying files during `CREATE DATABASE` and `ALTER DATABASE SET TABLESPACE` (PostgreSQL 18+).
262
309
263
-
Recommendation: Use **clone** if your filesystem supports it - dramatically faster (200-600ms for 100s of GB) and initially consumes zero extra disk space.
310
+
> [!TIP]
311
+
> Use `clone` if your filesystem supports it - dramatically faster (200-600ms for 100s of GB) and initially consumes zero extra disk space.
264
312
recomendations:
265
313
"Instant database clones with PostgreSQL 18": https://boringsql.com/posts/instant-database-clones/
266
314
"Instant Per-Branch Databases with PostgreSQL 18's clone": https://medium.com/axial-engineering/instant-per-branch-databases-with-postgresql-18s-clone-file-copy-and-copy-on-write-filesystems-1b1930bddbaa
@@ -273,9 +321,10 @@ categories:
273
321
Pool from which all background workers are drawn. Must accommodate:
274
322
- Parallel query workers (`max_parallel_workers`)
275
323
- Logical replication workers
276
-
- Extensions (pg_stat_statements, etc.)
324
+
- Extensions (`pg_stat_statements`, etc.)
277
325
278
-
Recommendation: Set to **CPU core count** or at least **25% of vCPUs**. Requires restart.
326
+
> [!TIP]
327
+
> Set to **CPU core count** or at least **25% of vCPUs**. Requires restart.
279
328
recomendations:
280
329
"PostgreSQL Performance Tuning Best Practices 2025": https://www.mydbops.com/blog/postgresql-parameter-tuning-best-practices
0 commit comments