> ## Documentation Index
> Fetch the complete documentation index at: https://docs.paradedb.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to Tune ParadeDB

> Settings for better read and write performance

ParadeDB uses Postgres' settings, which can be found in the `postgresql.conf` file. To find your `postgresql.conf` file, use `SHOW`.

```sql theme={null}
SHOW config_file;
```

These settings can be changed in several ways:

1. By editing the `postgresql.conf` file and restarting Postgres. This makes the setting permanent for all sessions. `postgresql.conf`
   accepts ParadeDB's custom `paradedb.*` settings.
2. By running `SET`. This temporarily changes the setting for the current session. Note that Postgres does not allow all `postgresql.conf` settings to be changed with `SET`.

```sql theme={null}
SET maintenance_work_mem = '8GB'
```

## Docker

When running ParadeDB in Docker, sensible default parameters are automatically configured based on the resources available to the container. For example, running a container with 4 CPUs and 8GB memory will cause the following to be appended to `postgresql.conf`. Be sure to adjust these parameters as you tune your deployment.

```postgresql.conf theme={null}
# Begin ParadeDB tuning recommendations
# Parameters based on auto-detected 4 CPUs and 8192MB RAM
shared_buffers = '2048MB'                     # 25% of RAM, capped at 16GB
effective_cache_size = '6144MB'               # 75% of RAM
maintenance_work_mem = '512MB'                # RAM / 16, capped at 2GB
work_mem = '20MB'                             # (RAM - shared_buffers) / (3 * max_connections), at least 15MB
max_parallel_workers = '20'                   # CPUs * 5
max_worker_processes = '28'                   # max_parallel_workers + 8
max_parallel_workers_per_gather = '2'         # CPUs / 2, at least 1
max_parallel_maintenance_workers = '2'        # CPUs / 2, at least 2, at most 8
# End ParadeDB tuning recommendations
```

To disable auto-tuning, set `PDB_TUNE=false` when you first run the container:

```
docker run \
    -e POSTGRES_USER=postgres \
    -e POSTGRES_PASSWORD=postgres \
    -e POSTGRES_DB=postgres \
    -p 5432:5432 \
    -e PDB_TUNE=false \
    -d paradedb/paradedb:latest
```

## CloudNativePG

If ParadeDB is deployed with [CloudNativePG](/deploy/self-hosted/kubernetes), these settings should be set in your
`.tfvars` file.

```hcl .tfvars theme={null}
postgresql = {
    parameters = {
      max_worker_processes                   = 76
      max_parallel_workers                   = 64
      # Note that paradedb.* settings must be wrapped in double quotes
      "paradedb.global_mutable_segment_rows" = 1000
    }
}
```
