Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions docs/client-drivers.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,28 @@ Connection conn = DriverManager.getConnection(url, "user", "password");

This doesn't cause any query routing issues; however, PgDog can't effectively cache the query syntax tree and has to parse queries _every time_ they are executed. This is computationally expensive. Consider switching to `psycopg` (version 3) or enabling our Rust-native query parser:

```toml
[general]
query_parser_engine = "pg_query_raw"
```
=== "pgdog.toml"
```toml
[general]
query_parser_engine = "pg_query_raw"
```
=== "Helm chart"
```yaml
queryParserEngine: pg_query_raw
```

We benchmarked this to be 5 times faster than normal `pg_query` parsing, which should help.

### Prisma

Prisma doesn't correctly use the `IN` clause with arrays, causing it to generate a very large number of unique prepared statements. This is not a big problem, but if left unchecked, can cause heavy memory usage in PgDog. Consider setting a lower prepared statements [cache limit](features/prepared-statements.md#cache-limit):

```toml
[general]
prepared_statements_limit = 1_000
```
=== "pgdog.toml"
```toml
[general]
prepared_statements_limit = 1_000
```
=== "Helm chart"
```yaml
preparedStatementsLimit: 1_000
```
23 changes: 19 additions & 4 deletions docs/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ PgDog uses the [TOML](https://toml.io/en/) configuration language for its two co
password = "pgdog"
database = "pgdog"
```
=== "Helm chart"
```yaml
databases:
- name: pgdog
host: 127.0.0.1
users:
- name: pgdog
password: pgdog
database: pgdog
```

By default, PgDog looks for both configuration files in the current working directory (`$PWD`). Alternatively, you can pass the
`--config=<path>` and `--users=<path>` arguments on startup.
Expand All @@ -47,10 +57,15 @@ Hot reload can be triggered by sending `SIGHUP` to the `pgdog` process or by con

To make things simpler, all units of time are in milliseconds. For example, if you want to set the pool checkout timeout to 5 seconds, convert it to 5000ms instead:

```toml
[general]
checkout_timeout = 5_000
```
=== "pgdog.toml"
```toml
[general]
checkout_timeout = 5_000
```
=== "Helm chart"
```yaml
checkoutTimeout: 5_000
```

!!! note "TOML syntax"
Since PgDog uses TOML, both `5000` and `5_000` are valid numbers. Configuration will fail to load if non-integer values are used, e.g. "5s" or "53.5".
Expand Down
13 changes: 9 additions & 4 deletions docs/configuration/pgdog.toml/admin.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,15 @@ icon: material/security
Admin database settings control access to the [admin](../../administration/index.md) database which contains real time statistics about internal operations
of PgDog. For example:

```toml
[admin]
password = "hunter2"
```
=== "pgdog.toml"
```toml
[admin]
password = "hunter2"
```
=== "Helm chart"
```yaml
adminPassword: "hunter2"
```

### `name`

Expand Down
30 changes: 21 additions & 9 deletions docs/configuration/pgdog.toml/control.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,27 @@ Control settings configure PgDog's connection to the PgDog control plane.
!!! note "Enterprise edition"
This feature is available in [Enterprise Edition](../../enterprise_edition/index.md) only.

```toml
[control]
endpoint = "http://localhost:8080"
token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
metrics_interval = 1000
stats_interval = 5000
active_queries_interval = 5000
request_timeout = 1000
```
=== "pgdog.toml"
```toml
[control]
endpoint = "http://localhost:8080"
token = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
metrics_interval = 1000
stats_interval = 5000
active_queries_interval = 5000
request_timeout = 1000
```
=== "Helm chart"
```yaml
control:
enabled: true
endpoint: "http://localhost:8080"
token: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
metricsInterval: 1000
statsInterval: 5000
activeQueriesInterval: 5000
requestTimeout: 1000
```

### `endpoint`

Expand Down
42 changes: 28 additions & 14 deletions docs/configuration/pgdog.toml/databases.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,34 @@ Database settings configure which databases PgDog is managing. This is a TOML li

For each database instance, add a `[[databases]]` entry to `pgdog.toml`. For example:

```toml
[[databases]]
name = "prod"
host = "10.0.0.1"
port = 5432
shard = 0

[[databases]]
name = "prod"
host = "10.0.0.2"
port = 5432
role = "replica"
shard = 0
```
=== "pgdog.toml"
```toml
[[databases]]
name = "prod"
host = "10.0.0.1"
port = 5432
shard = 0

[[databases]]
name = "prod"
host = "10.0.0.2"
port = 5432
role = "replica"
shard = 0
```
=== "Helm chart"
```yaml
databases:
- name: prod
host: 10.0.0.1
port: 5432
shard: 0
- name: prod
host: 10.0.0.2
port: 5432
role: replica
shard: 0
```

### `name`

Expand Down
19 changes: 13 additions & 6 deletions docs/configuration/pgdog.toml/memory.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,19 @@ icon: material/memory

Memory settings control buffer sizes used by PgDog for network I/O and task execution.

```toml
[memory]
net_buffer = 4096
message_buffer = 4096
stack_size = 2097152
```
=== "pgdog.toml"
```toml
[memory]
net_buffer = 4096
message_buffer = 4096
stack_size = 2097152
```
=== "Helm chart"
```yaml
memoryNetBuffer: 4096
memoryMessageBuffer: 4096
memoryStackSize: 2097152
```

### `net_buffer`

Expand Down
23 changes: 16 additions & 7 deletions docs/configuration/pgdog.toml/mirroring.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@ icon: material/mirror-rectangle

For example:

```toml
[[mirroring]]
source_db = "source"
destination_db = "dest"
queue_length = 500
exposure = 0.1
```
=== "pgdog.toml"
```toml
[[mirroring]]
source_db = "source"
destination_db = "dest"
queue_length = 500
exposure = 0.1
```
=== "Helm chart"
```yaml
mirrors:
- sourceDb: source
destinationDb: dest
queueLength: 500
exposure: 0.1
```

### `source_db`

Expand Down
25 changes: 17 additions & 8 deletions docs/configuration/pgdog.toml/network.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@ icon: material/network

PgDog speaks the Postgres protocol which, underneath, uses TCP. Optimal TCP settings are necessary to quickly recover from database incidents. For example:

```toml
[tcp]
keepalive = true
time = 60_000
interval = 60_000
retries = 3
user_timeout = 5_000
```
=== "pgdog.toml"
```toml
[tcp]
keepalive = true
time = 60_000
interval = 60_000
retries = 3
user_timeout = 5_000
```
=== "Helm chart"
```yaml
tcpKeepalive: true
tcpTime: 60_000
tcpInterval: 60_000
tcpRetries: 3
tcpUserTimeout: 5_000
```

To be consistent with the rest of PgDog documentation, units of time are in milliseconds. However, many TCP implementations only support seconds. Consider using round units, e.g., `1_000` milliseconds = 1 second.

Expand Down
35 changes: 24 additions & 11 deletions docs/configuration/pgdog.toml/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,20 @@ icon: material/power-plug

Plugins are a TOML list, so for each plugin you want to enable, add a `[[plugins]]` entry to `pgdog.toml`. For example:

```toml
[[plugins]]
name = "bob_router"

[[plugins]]
name = "alice_router"
```
=== "pgdog.toml"
```toml
[[plugins]]
name = "bob_router"

[[plugins]]
name = "alice_router"
```
=== "Helm chart"
```yaml
plugins:
- name: bob_router
- name: alice_router
```

!!! note
Plugins can only be configured at PgDog startup. They cannot be changed after
Expand All @@ -27,9 +34,15 @@ name is `router`, PgDog will look for `librouter.so` on Linux, `librouter.dll` o

Additionally, you can pass the relative or absolute path to the shared library itself:

```toml
[[plugins]]
name = "/opt/plugins/librouter.so"
```
=== "pgdog.toml"
```toml
[[plugins]]
name = "/opt/plugins/librouter.so"
```
=== "Helm chart"
```yaml
plugins:
- name: /opt/plugins/librouter.so
```

Make sure the user running PgDog has read & execute permissions on the library.
23 changes: 16 additions & 7 deletions docs/configuration/pgdog.toml/rewrite.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,22 @@ icon: material/alpha-r-box-outline

The `rewrite` section controls PgDog's automatic SQL rewrites for sharded databases. It affects sharding key updates and multi-tuple inserts. Either one can be toggled separately:

```toml
[rewrite]
enabled = false
shard_key = "error"
split_inserts = "error"
primary_key = "ignore"
```
=== "pgdog.toml"
```toml
[rewrite]
enabled = false
shard_key = "error"
split_inserts = "error"
primary_key = "ignore"
```
=== "Helm chart"
```yaml
rewrite:
enabled: false
shardKey: "error"
splitInserts: "error"
primaryKey: "ignore"
```

| Setting | Description | Default |
| --- | --- | --- |
Expand Down
Loading
Loading