Skip to content

Commit

Permalink
book: simple query/statement -> unprepared query
Browse files Browse the repository at this point in the history
  • Loading branch information
muzarski committed Apr 25, 2024
1 parent 880d7b0 commit 6a86b6f
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 35 deletions.
6 changes: 3 additions & 3 deletions docs/source/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- [Quick start](quickstart/quickstart.md)
- [Creating a project](quickstart/create-project.md)
- [Running Scylla using Docker](quickstart/scylla-docker.md)
- [Connecting and running a simple query](quickstart/example.md)
- [Connecting and running an unprepared query](quickstart/example.md)

- [Migration guides](migration-guides/migration-guides.md)
- [Adjusting code to changes in serialization API introduced in 0.11](migration-guides/0.11-serialization.md)
Expand All @@ -16,7 +16,7 @@
- [TLS](connecting/tls.md)

- [Making queries](queries/queries.md)
- [Simple query](queries/simple.md)
- [Unprepared query](queries/simple.md)
- [Query values](queries/values.md)
- [Query result](queries/result.md)
- [Prepared query](queries/prepared.md)
Expand Down Expand Up @@ -68,7 +68,7 @@
- [Logging](logging/logging.md)

- [Query tracing](tracing/tracing.md)
- [Tracing a simple/prepared query](tracing/basic.md)
- [Tracing an unprepared/prepared query](tracing/basic.md)
- [Tracing a paged query](tracing/paged.md)
- [Tracing `Session::prepare`](tracing/prepare.md)
- [Query Execution History](tracing/query-history.md)
Expand Down
2 changes: 1 addition & 1 deletion docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Although optimized for Scylla, the driver is also compatible with [Apache Cassan
* [Quick start](quickstart/quickstart.md) - Setting up a Rust project using `scylla-rust-driver` and running a few queries
* [Migration guides](migration-guides/migration-guides.md) - How to update the code that used an older version of this driver
* [Connecting to the cluster](connecting/connecting.md) - Configuring a connection to scylla cluster
* [Making queries](queries/queries.md) - Making different types of queries (simple, prepared, batch, paged)
* [Making queries](queries/queries.md) - Making different types of queries (unprepared, prepared, batch, paged)
* [Execution profiles](execution-profiles/execution-profiles.md) - Grouping query execution configuration options together and switching them all at once
* [Data Types](data-types/data-types.md) - How to use various column data types
* [Load balancing](load-balancing/load-balancing.md) - Load balancing configuration
Expand Down
4 changes: 2 additions & 2 deletions docs/source/migration-guides/0.11-serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ As explained in the [Background](#background) section, the driver uses data retu

> **NOTE:** The driver will skip preparation if it detects that the list of values for the statement is empty, as there is nothing to be type checked.
If you send simple statements along with non-empty lists of values, the slowdown will be as follows:
If you send unprepared queries along with non-empty lists of values, the slowdown will be as follows:

- For `Session::query`, the driver will prepare the statement before sending it, incurring an additional round-trip.
- For `Session::batch`, the driver will send a prepare request for each *unique* unprepared statement with a non-empty list of values. **This is done serially!**

In both cases, if the additional roundtrips are unacceptable, you should prepare the statements beforehand and reuse them - which aligns with our general recommendation against use of simple statements in performance sensitive scenarios.
In both cases, if the additional roundtrips are unacceptable, you should prepare the statements beforehand and reuse them - which aligns with our general recommendation against use of unprepared queries in performance sensitive scenarios.

### Migrating from old to new traits *gradually*

Expand Down
16 changes: 8 additions & 8 deletions docs/source/queries/batch.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Batch statement

A batch statement allows to execute many data-modifying statements at once.\
These statements can be [simple](simple.md) or [prepared](prepared.md).\
These statements can be [unprepared](simple.md) or [prepared](prepared.md).\
Only `INSERT`, `UPDATE` and `DELETE` statements are allowed.

```rust
Expand All @@ -16,12 +16,12 @@ use scylla::prepared_statement::PreparedStatement;
// Create a batch statement
let mut batch: Batch = Default::default();

// Add a simple statement to the batch using its text
// Add an unprepared query to the batch using its text
batch.append_statement("INSERT INTO ks.tab(a, b) VALUES(1, 2)");

// Add a simple statement created manually to the batch
let simple: Query = Query::new("INSERT INTO ks.tab (a, b) VALUES(3, 4)");
batch.append_statement(simple);
// Add an unprepared query statement created manually to the batch
let unprepared: Query = Query::new("INSERT INTO ks.tab (a, b) VALUES(3, 4)");
batch.append_statement(unprepared);

// Add a prepared statement to the batch
let prepared: PreparedStatement = session
Expand All @@ -41,8 +41,8 @@ session.batch(&batch, batch_values).await?;
```

> ***Warning***\
> Using simple statements with bind markers in batches is strongly discouraged.
> For each simple statement with a non-empty list of values in the batch,
> Using unprepared queries with bind markers in batches is strongly discouraged.
> For each unprepared query with a non-empty list of values in the batch,
> the driver will send a prepare request, and it will be done **sequentially**.
> Results of preparation are not cached between `Session::batch` calls.
> Consider preparing the statements before putting them into the batch.
Expand Down Expand Up @@ -103,7 +103,7 @@ See [Batch API documentation](https://docs.rs/scylla/latest/scylla/statement/bat
for more options

### Batch values
Batch takes a tuple of values specified just like in [simple](simple.md) or [prepared](prepared.md) queries.
Batch takes a tuple of values specified just like in [unprepared](simple.md) or [prepared](prepared.md) queries.

Length of batch values must be equal to the number of statements in a batch.\
Each statement must have its values specified, even if they are empty.
Expand Down
6 changes: 3 additions & 3 deletions docs/source/queries/paged.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Sometimes query results might not fit in a single page. Paged queries
allow to receive the whole result page by page.

`Session::query_iter` and `Session::execute_iter` take a [simple query](simple.md) or a [prepared query](prepared.md)
`Session::query_iter` and `Session::execute_iter` take an [unprepared query](simple.md) or a [prepared query](prepared.md)
and return an `async` iterator over result `Rows`.

> ***Warning***\
Expand All @@ -14,7 +14,7 @@ and return an `async` iterator over result `Rows`.
> use `Session::execute_iter`.
### Examples
Use `query_iter` to perform a [simple query](simple.md) with paging:
Use `query_iter` to perform an [unprepared query](simple.md) with paging:
```rust
# extern crate scylla;
# extern crate futures;
Expand Down Expand Up @@ -65,7 +65,7 @@ while let Some(next_row_res) = rows_stream.next().await {
# }
```

Query values can be passed to `query_iter` and `execute_iter` just like in a [simple query](simple.md)
Query values can be passed to `query_iter` and `execute_iter` just like in an [unprepared query](simple.md)

### Configuring page size
It's possible to configure the size of a single page.
Expand Down
2 changes: 1 addition & 1 deletion docs/source/queries/queries.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Making queries

This driver supports all query types available in Scylla:
* [Simple queries](simple.md)
* [Unprepared queries](simple.md)
* Easy to use
* Poor performance
* Primitive load balancing
Expand Down
16 changes: 8 additions & 8 deletions docs/source/queries/simple.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# Simple query
# Unprepared query

Simple query takes query text and values and simply executes them on a `Session`:
Unprepared query takes query text and values and simply executes them on a `Session`:
```rust
# extern crate scylla;
# use scylla::Session;
# use std::error::Error;
# async fn simple_query_example(session: &Session) -> Result<(), Box<dyn Error>> {
# async fn unprepared_query_example(session: &Session) -> Result<(), Box<dyn Error>> {
// Insert a value into the table
let to_insert: i32 = 12345;
session
Expand All @@ -16,7 +16,7 @@ session
```

> ***Warning***\
> Don't use simple query to receive large amounts of data.\
> Don't use unprepared query to receive large amounts of data.\
> By default the query is unpaged and might cause heavy load on the cluster.\
> In such cases set a page size and use [paged query](paged.md) instead.\
>
Expand Down Expand Up @@ -92,15 +92,15 @@ while let Some(read_row) = iter.next().transpose()? {
# Ok(())
# }
```
> In cases where page size is set, simple query returns only a single page of results.\
> In cases where page size is set, unpreapred query returns only a single page of results.\
> To receive all pages use a [paged query](paged.md) instead.\
See [Query result](result.md) for more information about handling query results

### Performance
Simple queries should not be used in places where performance matters.\
Unprepared queries should not be used in places where performance matters.\
If performance matters use a [Prepared query](prepared.md) instead.

With simple query the database has to parse query text each time it's executed, which worsens performance.\
With unprepared query the database has to parse query text each time it's executed, which worsens performance.\

Additionally token and shard aware load balancing does not work with simple queries. They are sent to random nodes.
Additionally token and shard aware load balancing does not work with unprepared queries. They are sent to random nodes.
2 changes: 1 addition & 1 deletion docs/source/quickstart/example.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Connecting and running a simple query
# Connecting and running an unprepared query

Now everything is ready to use the driver.
Here is a small example:
Expand Down
2 changes: 1 addition & 1 deletion docs/source/quickstart/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Quick Start


In this chapter we will set up a Rust project and run a few simple queries.
In this chapter we will set up a Rust project and run a few unprepared queries.

Topics Include:

Expand Down
2 changes: 1 addition & 1 deletion docs/source/retry-policy/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let session: Session = SessionBuilder::new()
# }
```

To use in a [simple query](../queries/simple.md):
To use in an [unprepared query](../queries/simple.md):
```rust
# extern crate scylla;
# use scylla::Session;
Expand Down
2 changes: 1 addition & 1 deletion docs/source/retry-policy/downgrading-consistency.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ let session: Session = SessionBuilder::new()
# }
```

To use in a [simple query](../queries/simple.md):
To use in an [unprepared query](../queries/simple.md):
```rust
# extern crate scylla;
# use scylla::Session;
Expand Down
2 changes: 1 addition & 1 deletion docs/source/retry-policy/fallthrough.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let session: Session = SessionBuilder::new()
# }
```

To use in a [simple query](../queries/simple.md):
To use in an [unprepared query](../queries/simple.md):
```rust
# extern crate scylla;
# use scylla::Session;
Expand Down
6 changes: 3 additions & 3 deletions docs/source/tracing/basic.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Tracing a simple/prepared/batch query
# Tracing an unprepared/prepared/batch query

[Simple query](../queries/simple.md), [prepared query](../queries/prepared.md) and [batch query](../queries/batch.md)
[Unprepared query](../queries/simple.md), [prepared query](../queries/prepared.md) and [batch query](../queries/batch.md)
return a `QueryResult` which contains a `tracing_id` if tracing was enabled.

### Tracing a simple query
### Tracing an unprepapred query
```rust
# extern crate scylla;
# extern crate uuid;
Expand Down
2 changes: 1 addition & 1 deletion docs/source/tracing/paged.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Tracing a paged query

A paged query performs multiple simple/prepared queries to query subsequent pages.\
A paged query performs multiple unprepared/prepared queries to query subsequent pages.\
If tracing is enabled the row iterator will contain a list of tracing ids for all performed queries.


Expand Down

0 comments on commit 6a86b6f

Please sign in to comment.