Skip to content

Commit 310e397

Browse files
committed
feat: add missing configs
1 parent 07b03aa commit 310e397

5 files changed

Lines changed: 167 additions & 7 deletions

File tree

docs/configuration/pgdog.toml/databases.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,7 @@ Overrides the [`idle_timeout`](general.md#idle_timeout) setting. Idle server con
105105
### `read_only`
106106

107107
Sets the `default_transaction_read_only` connection parameter to `on` on all server connections to this database. Clients can still override it with `SET`.
108+
109+
### `server_lifetime`
110+
111+
Overrides the [`server_lifetime`](general.md#server_lifetime) setting. Server connections older than this will be closed when returned to the pool.

docs/configuration/pgdog.toml/general.md

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,12 @@ Delay running idle healthchecks at PgDog startup to give databases (and pools) t
141141

142142
Default: **`5_000`** (5s)
143143

144+
### `healthcheck_timeout`
145+
146+
Maximum amount of time to wait for a healthcheck query to complete.
147+
148+
Default: **`5_000`** (5s)
149+
144150
### `connection_recovery`
145151

146152
Controls if server connections are recovered or dropped if a client abruptly disconnects.
@@ -237,6 +243,12 @@ Close client connections that have been idle, i.e., haven't sent any queries, fo
237243

238244
Default: **`none`** (disabled)
239245

246+
### `client_idle_in_transaction_timeout`
247+
248+
Close client connections that have been idle inside a transaction for this amount of time. This prevents clients from holding server connections indefinitely while in a transaction.
249+
250+
Default: **`none`** (disabled)
251+
240252
### `client_login_timeout`
241253

242254
Maximum amount of time new clients have to complete authentication. Clients that don't will be disconnected.
@@ -261,6 +273,17 @@ Which strategy to use for load balancing read queries. See [load balancer](../..
261273

262274
Default: **`random`**
263275

276+
### `read_write_strategy`
277+
278+
How aggressive the query parser should be in determining read vs. write queries.
279+
280+
Available options:
281+
282+
- `conservative` (default): transactions are writes, standalone `SELECT` are reads
283+
- `aggressive`: use first statement inside a transaction for determining query route
284+
285+
Default: **`conservative`**
286+
264287
### `read_write_split`
265288

266289
How to handle the separation of read and write queries.
@@ -449,10 +472,25 @@ Available options:
449472
### `reload_schema_on_ddl`
450473

451474
!!! warning
452-
This setting is intended for local development / CI / single node PgDog deployments.
453-
475+
This setting requires [PgDog Enterprise Edition](../../enterprise_edition/index.md) to work as expected. If using the open source edition,
476+
it will only work with single-node PgDog deployments, e.g., in local development or CI.
477+
454478
Automatically reload the schema cache used by PgDog to route queries upon detecting DDL statements (e.g., `CREATE TABLE`, `ALTER TABLE`, etc.).
455479

480+
Default: **`true`** (enabled)
481+
482+
### `load_schema`
483+
484+
Controls whether PgDog loads the database schema at startup for query routing.
485+
486+
Available options:
487+
488+
- `on`: always load schema on startup
489+
- `off`: disable loading schema
490+
- `auto` (default): load schema if number of database shards is greater than 1
491+
492+
Default: **`auto`**
493+
456494
## Logging
457495

458496
### `log_connections`
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
icon: material/memory
3+
---
4+
5+
# Memory
6+
7+
Memory settings control buffer sizes used by PgDog for network I/O and task execution.
8+
9+
```toml
10+
[memory]
11+
net_buffer = 4096
12+
message_buffer = 4096
13+
stack_size = 2097152
14+
```
15+
16+
### `net_buffer`
17+
18+
Size of the network read buffer in bytes. This buffer is used for reading data from client and server connections.
19+
20+
Default: **`4096`** (4 KiB)
21+
22+
### `message_buffer`
23+
24+
Size of the message buffer in bytes. This buffer is used for assembling PostgreSQL protocol messages.
25+
26+
Default: **`4096`** (4 KiB)
27+
28+
### `stack_size`
29+
30+
Stack size for Tokio tasks in bytes. Increase this if you encounter stack overflow errors with complex queries.
31+
32+
Default: **`2097152`** (2 MiB)

docs/configuration/pgdog.toml/rewrite.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@ The `rewrite` section controls PgDog's automatic SQL rewrites for sharded databa
1111
enabled = false
1212
shard_key = "error"
1313
split_inserts = "error"
14+
primary_key = "ignore"
1415
```
1516

1617
| Setting | Description | Default |
1718
| --- | --- | --- |
1819
| `enabled` | Enables/disables the query rewrite engine. | `false` |
1920
| `shard_key` | Behavior when an `UPDATE` changes a sharding key: `error` rejects the statement,<br>`rewrite` migrates the row between shards,<br>`ignore` forwards it unchanged. | `"error"` |
2021
| `split_inserts` | Behavior when a sharded table receives a multi-row `INSERT`: `error` rejects the statement, `rewrite` fans the rows out to their shards, `ignore` forwards it unchanged. | `"error"` |
22+
| `primary_key` | Behavior when an `INSERT` is missing a `BIGINT` primary key: `error` rejects the statement,<br>`rewrite` auto-injects `pgdog.unique_id()` for missing keys,<br>`ignore` allows the INSERT without modification. | `"ignore"` |
2123

2224
!!! note "Two-phase commit"
2325
Consider enabling [two-phase commit](../../features/sharding/2pc.md) when either feature is set to `rewrite`. Without it, rewrites are committed shard-by-shard and can leave partial changes if a transaction fails.

docs/configuration/pgdog.toml/sharded_tables.md

Lines changed: 89 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,16 @@ Currently, PgDog supports sharding `BIGINT` (and `BIGSERIAL`), `UUID`, `VARCHAR`
5757

5858
The name of the database in [`[[databases]]`](databases.md) section in which the table is located. PgDog supports sharding thousands of databases and tables in the same configuration file.
5959

60-
### `table`
60+
### `schema`
61+
62+
The name of the PostgreSQL schema where the sharded table is located. This is optional. If not set, all schemas will be sharded.
63+
64+
### `name`
6165

6266
The name of the PostgreSQL table. Only columns explicitly referencing that table will be sharded.
6367

6468
The name must not contain the schema name, just the table name.
6569

66-
!!! note "Postgres schemas"
67-
Disambiguating tables in different schemas isn't currently supported and all of them will be sharded.
68-
6970
### `column`
7071

7172
The name of the sharded column.
@@ -79,6 +80,25 @@ The data type of the column. Currently supported options are:
7980
- `varchar`
8081
- `vector`
8182

83+
### `hasher`
84+
85+
The hash function to use for sharding. Available options:
86+
87+
- `postgres` (default) - PostgreSQL's native hash function
88+
- `sha1` - SHA-1 hash function
89+
90+
### `centroids`
91+
92+
For vector sharding, specify the centroid vectors directly in the configuration. This is useful for small centroid sets.
93+
94+
### `centroids_path`
95+
96+
Path to a JSON file containing centroid vectors. This is useful when centroids are large (1000+ dimensions) and impractical to embed in `pgdog.toml`.
97+
98+
### `centroid_probes`
99+
100+
Number of centroids to probe during vector similarity search. If not specified, defaults to the square root of the number of centroids.
101+
82102
## Omnisharded tables
83103

84104
[Omnisharded](../../features/sharding/omnishards.md) tables are tables that have the same data on all shards. They typically are small and contain metadata, e.g., list of countries, cities, etc., and are used in joins. PgDog allows to read from these tables directly and load balances traffic evenly across all shards.
@@ -113,9 +133,56 @@ By default, PgDog uses hash-based sharding, with data evenly split between shard
113133

114134
To configure either one, you need to specify the value-to-shard mapping in the configuration.
115135

136+
## Mapping fields
137+
138+
!!! note
139+
The `column`, `table`, and `schema` fields must match a corresponding `[[sharded_tables]]` entry.
140+
141+
### `database`
142+
143+
The name of the database in [`[[databases]]`](databases.md) section.
144+
145+
### `column`
146+
147+
The name of the column to match for routing. Must match a `column` in `[[sharded_tables]]`.
148+
149+
### `table`
150+
151+
The name of the table to match. Must match a `name` in `[[sharded_tables]]` if specified there. This is optional.
152+
153+
### `schema`
154+
155+
The name of the PostgreSQL schema to match. Must match a `schema` in `[[sharded_tables]]` if specified there. This is optional.
156+
157+
### `kind`
158+
159+
The type of mapping. Available options:
160+
161+
- `list`: match specific values (i.e., `PARTITION BY LIST`)
162+
- `range`: match a range of values (i.e., `PARTITION BY RANGE`)
163+
- `default`: fallback for unmatched values (list-based sharding only)
164+
165+
### `values`
166+
167+
For `list` mappings, the set of values that route to this shard.
168+
169+
### `start`
170+
171+
For `range` mappings, the starting value (inclusive).
172+
173+
### `end`
174+
175+
For `range` mappings, the ending value (exclusive).
176+
177+
### `shard`
178+
179+
The target shard number for matched queries.
180+
181+
## Mapping examples
182+
116183
### Lists
117184

118-
Lists are defined as a list of values and a corresponding shard number. Just like sharded tables, the mapping is database and column (and optionally, table) specific:
185+
Lists are defined as a list of values and a corresponding shard number. Just like sharded tables, the mapping is database and column (and optionally, table and schema) specific:
119186

120187
```toml
121188
[[sharded_mappings]]
@@ -153,3 +220,20 @@ shard = 0
153220
UPDATE users SET deleted_at = NOW()
154221
WHERE tenant_id IN (1, 2, 5, 10, 56)
155222
```
223+
224+
### Default
225+
226+
The `default` kind specifies a fallback shard for values that don't match any list mapping:
227+
228+
```toml
229+
[[sharded_mappings]]
230+
database = "prod"
231+
column = "tenant_id"
232+
kind = "default"
233+
shard = 2
234+
```
235+
236+
Any sharding key value that doesn't match an explicit list mapping will be routed to the default shard.
237+
238+
!!! note
239+
The `default` kind only works with list-based sharding, not range-based sharding.

0 commit comments

Comments
 (0)