Skip to content
Open
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
16 changes: 14 additions & 2 deletions docs/features/connection-pooler/prepared-statements.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,20 @@ You can enable simple statement rewrites in [`pgdog.toml`](../../configuration/p
Statements prepared using this method can be executed normally with `Bind` and `Execute` messages. Result data types can be inspected with `Describe`, just
like a regular prepared statement.

!!! warning "Sharding support"
Currently, `EXECUTE` command for [sharded](../sharding/index.md) prepared statements is not supported. Such commands will be sent to all shards.
### Sharding support

With `prepared_statements = "full"`, PgDog uses the statement saved by `PREPARE` together with the values passed to `EXECUTE` to route the query. This supports direct-to-shard and cross-shard routing for `SELECT`, `INSERT`, `UPDATE`, and `DELETE`.

For example, when `id` is the sharding key:

```postgresql
PREPARE user_by_id AS
SELECT * FROM users WHERE id = $1;

EXECUTE user_by_id(11);
```

PgDog uses `11` to route the `EXECUTE` command to the shard that owns that row, rather than sending it to every shard.

## Unnamed statements

Expand Down