Skip to content

Commit e9c763c

Browse files
committed
Add DB activity based routing
1 parent b37d105 commit e9c763c

File tree

9 files changed

+739
-36
lines changed

9 files changed

+739
-36
lines changed

CONFIG.md

+39
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,45 @@ If the client doesn't specify, PgCat routes traffic to this role by default.
309309
`replica` round-robin between replicas only without touching the primary,
310310
`primary` all queries go to the primary unless otherwise specified.
311311

312+
### db_activity_based_routing
313+
```
314+
path: pools.<pool_name>.db_activity_based_routing
315+
default: false
316+
```
317+
318+
If enabled, PgCat will route queries to the primary if the queried table was recently written to.
319+
Only relevant when `query_parser_enabled` *and* `query_parser_read_write_splitting` is enabled.
320+
321+
##### Considerations:
322+
- *This feature is experimental and may not work as expected.*
323+
- This feature only works when the same PgCat instance is used for both reads and writes to the database.
324+
- This feature is not relevant when the primary is not part of the pool of databases used for load balancing of read queries.
325+
- If more than one PgCat instance is used for HA purposes, this feature will not work as expected. A way to still make it work is by using sticky sessions.
326+
327+
### db_activity_based_ms_init_delay
328+
```
329+
path: pools.<pool_name>.db_activity_based_ms_init_delay
330+
default: 100
331+
```
332+
333+
The delay in milliseconds before the first activity-based routing check is performed.
334+
335+
### db_activity_ttl
336+
```
337+
path: pools.<pool_name>.db_activity_ttl
338+
default: 900
339+
```
340+
341+
The time in seconds after which a DB is considered inactive when no queries/updates are performed to it.
342+
343+
### table_mutation_cache_ms_ttl
344+
```
345+
path: pools.<pool_name>.table_mutation_cache_ms_ttl
346+
default: 50
347+
```
348+
349+
The time in milliseconds after a write to a table that all queries to that table will be routed to the primary.
350+
312351
### prepared_statements_cache_size
313352
```
314353
path: general.prepared_statements_cache_size

0 commit comments

Comments
 (0)