<style>
/* Make the ... appear in front of the spec items in the right hand nav menu  */
.md-sidebar--secondary span.md-ellipsis {
	direction: rtl;
}
</style>

# Nais Postgres reference

<!--
  This documentation was automatically generated by https://github.com/nais/pgrator/actions
  
  DO NOT MAKE MANUAL CHANGES TO THIS FILE, THEY WILL BE OVERWRITTEN!
-->

> **Experimental feature**
> This feature is an alpha feature, and is subject to API change, instability or removal.
> See the [main Postgres page](/persistence/postgres.md) for more information.

This document describes all possible configuration values in the `Postgres` spec, commonly known as the `postgres.yaml` file. Each `Postgres` is one CNPG cluster managed by pgrator. `spec.activeBranch` is deprecated: branches were retired, and only `main` (or omitting it) is accepted.

## activeBranch

ActiveBranch is deprecated: branches were retired. Only `main` (or empty)
is accepted; the field is kept so existing manifests stay valid.

Type: `string`<br />
Required: `false`<br />

## autoExplain

AutoExplain logs JSON execution plans for statements taking at least one second.
Includes actual row counts and buffer usage, with per-node timing and parameter
values disabled. Adds instrumentation overhead. Enabling or disabling it on
an existing cluster requires a rolling restart.

Type: `boolean`<br />
Required: `false`<br />

> **Example**
> ```yaml
> spec:
>   autoExplain: true
> ```

## extensions

Extensions to activate in the application database. Removing an entry drops the extension
(without CASCADE); postgis and timescaledb stay mounted and preloaded until the drop
succeeds. The drop fails, and is retried, while other objects depend on the extension.

Type: `array`<br />
Required: `false`<br />

> **Example**
> ```yaml
> spec:
>   extensions:
>     - name: postgis
> ```

### extensions[].name

Name of the extension, as used in CREATE EXTENSION. postgis and timescaledb are mounted
from the configured CNPG image catalog (timescaledb is also preloaded); the rest are bundled
with the Postgres image. pg_stat_statements and pgaudit are managed by the platform and
cannot be requested.

Type: `enum`<br />
Required: `true`<br />
Allowed values: `amcheck`, `bloom`, `btree_gin`, `btree_gist`, `citext`, `cube`, `earthdistance`, `fuzzystrmatch`, `hstore`, `intarray`, `isn`, `lo`, `ltree`, `pageinspect`, `pg_buffercache`, `pg_freespacemap`, `pg_logicalinspect`, `pg_prewarm`, `pg_trgm`, `pg_visibility`, `pg_walinspect`, `pgcrypto`, `pgrowlocks`, `pgstattuple`, `postgis`, `seg`, `sslinfo`, `tablefunc`, `tcn`, `timescaledb`, `tsm_system_rows`, `tsm_system_time`, `unaccent`, `vector`<br />

> **Example**
> ```yaml
> spec:
>   extensions:
>     - name: postgis
> ```

## highAvailability

HighAvailability adds a third instance and enables synchronous replication.

A cluster always runs a primary and a standby, so failover is available either
way. What this adds is the guarantee that an acknowledged commit survives
losing the primary, at the cost of write latency.

Type: `boolean`<br />
Required: `false`<br />

> **Example**
> ```yaml
> spec:
>   highAvailability: true
> ```

## majorVersion

MajorVersion of Postgres to use.

Type: `enum`<br />
Required: `true`<br />
Allowed values: `18`<br />

> **Example**
> ```yaml
> spec:
>   majorVersion: "18"
> ```

## pitr

PITR configures the continuous point-in-time recovery window.

Type: `object`<br />
Required: `false`<br />

> **Example**
> ```yaml
> spec:
>   pitr:
>     windowDays: 2
> ```

### pitr.windowDays

WindowDays is how many days back in time the database can be recovered to.
Older recovery data (base backups and WAL) is removed by barman, which checks
periodically. The base backup preceding the window is kept, so data up to a day
older may remain. Allowed range is 2 to 30 days.
Defaults to 2 when omitted.

Type: `integer`<br />
Required: `false`<br />
Value range: `2`-`30`<br />

> **Example**
> ```yaml
> spec:
>   pitr:
>     windowDays: 2
> ```

## resources

Resources configures compute and disk for the Postgres cluster.

Type: `object`<br />
Required: `false`<br />

> **Example**
> ```yaml
> spec:
>   resources:
>     cpu: 100m
>     diskSize: 10Gi
>     memory: 512Mi
> ```

### resources.cpu

Cpu is the CPU resources for the Postgres cluster.

Type: `integer` or `string`<br />
Required: `false`<br />
Pattern: `^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$`<br />

> **Example**
> ```yaml
> spec:
>   resources:
>     cpu: 100m
> ```

### resources.diskSize

DiskSize is the disk size for the Postgres cluster. Minimum is 5Gi.

Type: `integer` or `string`<br />
Required: `false`<br />
Pattern: `^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$`<br />

> **Example**
> ```yaml
> spec:
>   resources:
>     diskSize: 10Gi
> ```

### resources.memory

Memory is the memory resources for the Postgres cluster.

Type: `integer` or `string`<br />
Required: `false`<br />
Pattern: `^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$`<br />

> **Example**
> ```yaml
> spec:
>   resources:
>     memory: 512Mi
> ```
