Skip to content

Commit a3ae971

Browse files
authored
Merge pull request #1704 from silentoplayz/codex/docs-support-postgres-pgvector
docs: correct PostgreSQL pool and pgvector index guidance
2 parents 6c6e7f6 + a95867d commit a3ae971

3 files changed

Lines changed: 8 additions & 18 deletions

File tree

‎docs/getting-started/advanced-topics/scaling.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Use a plain `postgresql://` URL. Open WebUI picks the async driver (psycopg 3) i
5454

5555
- Open WebUI does **not** migrate data between databases, so plan this before you have production data in SQLite.
5656
- **Connection pool.** With [`DATABASE_POOL_SIZE`](/reference/env-configuration#database_pool_size) unset, each process uses SQLAlchemy's default of 5 connections plus 10 overflow. Once you set `DATABASE_POOL_SIZE`, the overflow default drops to `0`, so set [`DATABASE_POOL_MAX_OVERFLOW`](/reference/env-configuration#database_pool_max_overflow) too. `DATABASE_POOL_SIZE=0` disables pooling. `DATABASE_POOL_SIZE=15` with `DATABASE_POOL_MAX_OVERFLOW=20` is a good start for busy instances.
57-
- **Every worker process has its own pools.** Each process holds two engines on `DATABASE_URL`, a sync one and an async one, and each can open `DATABASE_POOL_SIZE + DATABASE_POOL_MAX_OVERFLOW` connections. With [`VECTOR_DB=pgvector`](/reference/env-configuration#vector_db), PGVector opens a third pool of [`PGVECTOR_POOL_SIZE`](/reference/env-configuration#pgvector_pool_size) + [`PGVECTOR_POOL_MAX_OVERFLOW`](/reference/env-configuration#pgvector_pool_max_overflow) connections (also 5 + 10 when `PGVECTOR_POOL_SIZE` is unset), even when `PGVECTOR_DB_URL` is unset and it shares the main database. The maximum number of connections is `(2 × (DATABASE_POOL_SIZE + DATABASE_POOL_MAX_OVERFLOW) + PGVector pool) × UVICORN_WORKERS × replicas`, where [`UVICORN_WORKERS`](/reference/env-configuration#uvicorn_workers) is the number of worker processes per replica (default 1). Keep that below PostgreSQL's `max_connections` (default 100) with room for other clients. With the values above, one worker and no PGVector, 3 replicas can open 210 connections, so raise `max_connections` or lower the pool sizes.
57+
- **Budget connections per database server.** With PostgreSQL pooling enabled, each worker has a synchronous and an asynchronous application pool. With `VECTOR_DB=pgvector`, an unset `PGVECTOR_DB_URL` defaults to `DATABASE_URL`. pgvector creates a separate engine for that URL even though it targets the same server. Count the pools that connect to each server and multiply by the total number of workers across replicas. See [PostgreSQL pool sizing](/reference/env-configuration#database_pool_size) for an example.
5858
- For single-instance pool tuning, see [Connection Pool Sizing](/troubleshooting/performance#connection-pool-sizing).
5959

6060
For credential handling and encryption at rest, see the [Database section of the Hardening guide](/getting-started/advanced-topics/hardening#database).

‎docs/reference/env-configuration.mdx‎

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3589,10 +3589,10 @@ If set to `false`, open-webui will assume the postgreSQL database where embeddin
35893589

35903590
- Type: `str`
35913591
- Options:
3592-
- `ivfflat`: Uses inverted file with flat compression, better for datasets with many dimensions.
3592+
- `ivfflat`: Groups vectors into lists and searches a subset of those lists.
35933593
- `hnsw`: Uses Hierarchical Navigable Small World graphs, generally provides better query performance.
3594-
- Default: Not specified (pgvector will use its default)
3595-
- Description: Specifies the index method for pgvector. The choice affects query performance and index build time.
3594+
- Default: unset. Open WebUI selects `ivfflat` for `vector` columns and `hnsw` for `halfvec` columns.
3595+
- Description: Specifies the index method for pgvector. If the existing `idx_document_chunk_vector` uses a different method, initialization fails and Open WebUI leaves the index in place. Plan a maintenance window to replace the index with one that uses the new method before restarting. Changing only the index method can reuse the stored embeddings.
35963596
- Persistence: Set via environment variable; applied at startup (not a `ConfigVar`).
35973597

35983598
:::info
@@ -8411,23 +8411,13 @@ Each SQLite connection carries its own page cache (`DATABASE_SQLITE_PRAGMA_CACHE
84118411

84128412
For deployments with many concurrent users, consider increasing both `DATABASE_POOL_SIZE` and `DATABASE_POOL_MAX_OVERFLOW`. A good starting point is `DATABASE_POOL_SIZE=15` and `DATABASE_POOL_MAX_OVERFLOW=20`.
84138413

8414-
**Important:** The combined total (`DATABASE_POOL_SIZE` + `DATABASE_POOL_MAX_OVERFLOW`) should remain well below your database server's `max_connections` limit. PostgreSQL defaults to 100 max connections, so keeping the combined total under 50-80 per Open WebUI instance is recommended to leave room for other clients and maintenance connections.
8415-
84168414
:::
84178415

8418-
:::warning Pool Size Multiplies with Concurrency
8419-
8420-
**Each Open WebUI process maintains its own independent connection pool.** This applies to every replica, whether Kubernetes pods, Docker Compose or Docker Swarm replicas, and to every Uvicorn worker inside one.
8421-
8422-
The actual maximum number of database connections is:
8423-
8424-
```
8425-
Total connections = (DATABASE_POOL_SIZE + DATABASE_POOL_MAX_OVERFLOW) × Number of processes/instances
8426-
```
8416+
:::warning PostgreSQL pools multiply with workers
84278417

8428-
For example, with `DATABASE_POOL_SIZE=15`, `DATABASE_POOL_MAX_OVERFLOW=20`, and 4 replicas, you could open up to **140 connections** (35 × 4).
8418+
Each Open WebUI worker has separate synchronous and asynchronous application engines. When pooling is enabled, each can open up to `DATABASE_POOL_SIZE + DATABASE_POOL_MAX_OVERFLOW` connections. For example, a size of 15 and overflow of 20 across four replicas with one worker each gives an application pool capacity of 280 connections (2 × 35 × 4).
84298419

8430-
When calculating pool settings, always account for this multiplier to avoid exhausting your database's `max_connections` limit. This is a fundamental limitation: connection pools cannot be shared across separate processes or containers.
8420+
With `VECTOR_DB=pgvector`, an unset `PGVECTOR_DB_URL` defaults to `DATABASE_URL`. The nonempty URL gives pgvector a separate engine governed by [its own pool settings](#pgvector_pool_size), even when it points to the same server. Count that pool against the server it connects to. Leave room under each server's `max_connections` for clients outside Open WebUI. These limits describe configured pools. Disabling pooling does not set a connection cap.
84318421

84328422
:::
84338423

‎docs/troubleshooting/performance.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ For high-concurrency PostgreSQL deployments, the default connection pool may be
108108

109109
SQLite uses its own pool sizing, see [SQLite Memory Footprint on Constrained Containers](#5-sqlite-memory-footprint-on-constrained-containers).
110110

111-
**Important:** The combined total (`DATABASE_POOL_SIZE` + `DATABASE_POOL_MAX_OVERFLOW`) should remain well below your database's `max_connections` limit. PostgreSQL defaults to 100 max connections, so keep the combined total under 50-80 per Open WebUI instance to leave room for other clients and maintenance operations.
111+
**Important:** For PostgreSQL, count the synchronous pool, asynchronous pool, and any pgvector pool that connects to the same database server. Multiply by the number of workers across replicas and leave room for other clients. See [PostgreSQL pool sizing](/reference/env-configuration#database_pool_size).
112112

113113
### Vector Database (RAG)
114114
For multi-user setups, the choice of Vector DB matters.

0 commit comments

Comments
 (0)