Skip to content

Commit 10556e3

Browse files
committed
book: mention benefits of prepared statements
1 parent 0c19bf6 commit 10556e3

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

docs/source/queries/prepared.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
Prepared queries provide much better performance than simple queries,
44
but they need to be prepared before use.
55

6+
Benefits that prepared statements have to offer:
7+
- Type safety - thanks to metadata provided by the server, the driver can verify bound values' types before serialization. This way, we can be always sure that the Rust type provided by the user is compatible (and if not, the error is returned) with the destined native type. The same applies for deserialization.
8+
- Performance - when executing a simple query with non-empty values list, the driver
9+
prepares the statement before execution. The reason for this is to provide type safety for simple queries. However, this implies 2 round trips per simple query execution. On the other hand, the cost of prepared statement's execution is only 1 round trip.
10+
- Improved load-balancing - using the statement metadata, the driver can compute a set of destined replicas for current statement execution. These replicas will be preferred when choosing the node (and shard) to send the request to. For more insight on this, see [performance section](#performance).
11+
612
```rust
713
# extern crate scylla;
814
# use scylla::Session;

0 commit comments

Comments
 (0)