From 39562130556bc90a88b8ca477d62bc152f2ba2dc Mon Sep 17 00:00:00 2001
From: Ben Prescott_ <bprescott@gitlab.com>
Date: Mon, 18 Nov 2024 06:03:31 +0000
Subject: [PATCH] PostgreSQL version support and tunables

---
 doc/install/requirements.md | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/doc/install/requirements.md b/doc/install/requirements.md
index 025f58c053e51..50b9b5400592e 100644
--- a/doc/install/requirements.md
+++ b/doc/install/requirements.md
@@ -50,7 +50,8 @@ For more information, see
 ## PostgreSQL
 
 [PostgreSQL](https://www.postgresql.org/) is the only supported database and is bundled with the Linux package.
-You can also use an [external PostgreSQL database](https://docs.gitlab.com/omnibus/settings/database.html#using-a-non-packaged-postgresql-database-management-server).
+You can also use an [external PostgreSQL database](https://docs.gitlab.com/omnibus/settings/database.html#using-a-non-packaged-postgresql-database-management-server)
+[which must be tuned correctly](#postgresql-tuning).
 
 Depending on the [number of users](../administration/reference_architectures/index.md),
 the PostgreSQL server should have:
@@ -63,7 +64,8 @@ For the following versions of GitLab, use these PostgreSQL versions:
 
 | GitLab version | Minimum PostgreSQL version | Maximum PostgreSQL version |
 | -------------- | -------------------------- | -------------------------- |
-| 17.x           | 14.9                       | 15.x                       |
+| 18.x           | 16.x (proposed in [epic 12172](https://gitlab.com/groups/gitlab-org/-/epics/12172)) | To be determined |
+| 17.x           | 14.x                       | 16.x ([tested against GitLab 16.10 and later](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/145298)) |
 | 16.x           | 13.6                       | 15.x ([tested against GitLab 16.1 and later](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/119344)) |
 | 15.x           | 12.10                      | 14.x ([tested against GitLab 15.11 only](https://gitlab.com/gitlab-org/gitlab/-/merge_requests/114624)), 13.x |
 
@@ -119,6 +121,17 @@ During Rails database migrations, GitLab might create or modify schemas or table
 Database migrations are tested against the schema definition in the GitLab codebase.
 If you modify any schema, [GitLab upgrades](../update/index.md) might fail.
 
+### PostgreSQL tuning
+
+Here are some required settings for externally managed PostgreSQL instances.
+
+| Tunable setting        | Required value | More information |
+|:-----------------------|:---------------|:-----------------|
+| `work_mem`             | minimum `8MB`  | This value is the Linux package default. In large deployments, if queries create temporary files, you should increase this setting. |
+| `maintenance_work_mem` | minimum `64MB` | You require [more for larger database servers](https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/8377#note_1728173087). |
+| `shared_buffers`       | minimum `2GB`  | You require more for larger database servers. The Linux package default is set to 25% of server RAM. |
+| `statement_timeout`    | maximum 1 min  | A statement timeout prevents runaway issues with locks and the database rejecting new clients. One minute matches the Puma rack timeout setting. |
+
 ## Puma
 
 The recommended [Puma](https://puma.io/) settings depend on your [installation](install_methods.md).
-- 
GitLab