Skip to content

Commit fcebf8d

Browse files
committed
spelling
1 parent 3333044 commit fcebf8d

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

docs/features/load-balancer/manual-routing.md

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ Query comments are supported in all types of queries, including prepared stateme
2121

2222
## Parameters
2323

24-
Startup parameters are connection-specific settings that are typically set on connection creation to configure database behavior. For example, this is how ORMs and web frameworks control settings like `application_name`, `work_mem`, `statement_timeout` and many others.
24+
Parameters are connection-specific settings that can be set on connection creation to configure database behavior. For example, this is how ORMs and web frameworks control settings like `application_name`, `statement_timeout` and many others.
2525

26-
The Postgres protocol doesn't have any restrictions on parameter names or values, and PgDog can choose to forward those settings to Postgres (or not).
26+
The Postgres protocol doesn't have any restrictions on parameter names or values, and PgDog has access to them at connection creation.
2727

28-
PgDog has two parameters that control which database is used for all queries on a client connection:
28+
The following two parameters allow you to control which database is used for all queries on a client connection:
2929

3030
| Parameter | Description |
3131
|-|-|
@@ -43,7 +43,7 @@ The `pgdog.shard` parameter accepts a shard number for any database specified in
4343

4444
### Setting the parameters
4545

46-
Setting the parameter at connection creation is PostgreSQL driver-specific. Some of the common drivers and frameworks are shown below.
46+
Configuring parameters at connection creation is PostgreSQL driver-specific. Some of the common drivers and frameworks are shown below.
4747

4848
#### Database URL
4949

@@ -57,7 +57,7 @@ Depending on the environment, the parameters may need to be URL-encoded, e.g., `
5757

5858
=== "asyncpg"
5959

60-
[asyncpg](https://pypi.org/project/asyncpg/) is a popular PostgreSQL driver for asynchronous Python applications. It allows you to set connection parameters when creating a connection:
60+
[asyncpg](https://pypi.org/project/asyncpg/) is a popular PostgreSQL driver for asynchronous Python applications. It allows you to set connection parameters on connection setup:
6161

6262
```python
6363
conn = await asyncpg.connect(
@@ -74,16 +74,13 @@ Depending on the environment, the parameters may need to be URL-encoded, e.g., `
7474

7575
=== "SQLAlchemy"
7676

77-
[SQLAlchemy](https://www.sqlalchemy.org/) is a popular Python ORM, which supports any number of PostgreSQL connection drivers. For example, if you're using `asyncpg`, you can set connection parameters as follows:
77+
[SQLAlchemy](https://www.sqlalchemy.org/) is a Python ORM, which supports any number of PostgreSQL connection drivers. For example, if you're using `asyncpg`, you can set connection parameters as follows:
7878

7979
```python
8080
engine = create_async_engine(
8181
"postgresql+asyncpg://pgdog:pgdog@10.0.0.0:6432/pgdog",
8282
pool_size=20,
83-
max_overflow=30,
84-
pool_timeout=30,
85-
pool_recycle=3600,
86-
pool_pre_ping=True,
83+
# [...]
8784
connect_args={"server_settings": {"pgdog.role": "primary"}},
8885
)
8986
```
@@ -103,31 +100,33 @@ Depending on the environment, the parameters may need to be URL-encoded, e.g., `
103100
options: "-c pgdog.role=replica -c pgdog.shard=0"
104101
```
105102

106-
These options are passed to the [`pg`](https://github.com/ged/ruby-pg) driver, so if you're using it directly, you can create connections manually like so:
103+
These options are passed to the [`pg`](https://github.com/ged/ruby-pg) driver. If you're using it directly, you can create connections like so:
107104

108105
```ruby
109106
require "pg"
110107

111108
conn = PG.connect(
112109
host: "10.0.0.0",
113-
# user, password, etc.
110+
# [...]
114111
options: "-c pgdog.role=primary -c pgdog.shard=1"
115112
)
116113
```
117114

118115
### Using `SET`
119116

120-
The PostgreSQL protocol supports setting connection parameters using the `SET` statement. This also works for configuring both `pgdog.role` and `pgdog.shard` parameters.
117+
The PostgreSQL protocol supports configuring connection parameters using the `SET` statement. This also works for configuring both `pgdog.role` and `pgdog.shard`.
121118

122-
For example, if you want all subsequent queries to be sent to the primary, you can execute the following statement:
119+
For example, to make sure all subsequent queries to be sent to the primary, you can execute the following statement:
123120

124121
```postgresql
125122
SET pgdog.role TO "primary";
126123
```
127124

125+
The parameter is persisted on the connection until it's closed or the parameter is changed with another `SET` statement.
126+
128127
#### Inside transactions
129128

130-
If you want to provide a transaction routing hint without affecting the rest of the connection, you can use `SET LOCAL`:
129+
If you want to provide a transaction routing hint without affecting the rest of the connection, you can use `SET LOCAL` instead:
131130

132131
```postgresql
133132
BEGIN;
@@ -154,17 +153,15 @@ In this example, all transaction statements (including the `BEGIN` statement) wi
154153

155154
In certain situations, the overhead of parsing queries may be too high, e.g., when your application can't use prepared statements.
156155

157-
If you've configured the desired database role (and/or shard) for each of your application connections, you can safely disable the query parser in [pgdog.toml](../../configuration/pgdog.toml/general.md#query_parser):
156+
If you've configured the desired database role (and/or shard) for each of your application connections, you can disable the query parser in [pgdog.toml](../../configuration/pgdog.toml/general.md#query_parser):
158157

159158
```toml
160159
[general]
161160
query_parser = "off"
162161
```
163162

164-
Once the parser is disabled, PgDog will rely solely on the `pgdog.role` and `pgdog.shard` parameters to make its routing decisions.
165-
166-
### Session state
163+
Once it's disabled, PgDog will rely solely on the `pgdog.role` and `pgdog.shard` parameters to make its routing decisions.
167164

168-
The query parser is used to intercept and interpret `SET` commands, which set session variables at runtime.
165+
### Session state & `SET`
169166

170-
If the parser is disabled and your application uses `SET` commands to configure the connection at startup, PgDog will not be able to guarantee that all connections have the correct session settings in [transaction mode](../transaction-mode.md).
167+
The query parser is used to intercept and interpret `SET` commands. If the parser is disabled and your application uses `SET` commands to configure the connection, PgDog will not be able to guarantee that all connections have the correct session settings in [transaction mode](../transaction-mode.md).

0 commit comments

Comments
 (0)