You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Uses `RowBinaryWithNamesAndTypes` or `RowBinary` formats over HTTP transport.
22
+
* By default, `RowBinaryWithNamesAndTypes` with database schema validation is used.
23
+
* It is possible to switch to `RowBinary`, which can potentially lead to increased performance ([see below](#validation)).
24
+
* There are plans to implement `Native` format over TCP.
23
25
* Supports TLS (see `native-tls` and `rustls-tls` features below).
24
26
* Supports compression and decompression (LZ4 and LZ4HC).
25
27
* Provides API for selecting.
@@ -29,9 +31,30 @@ Official pure Rust typed client for ClickHouse DB.
29
31
30
32
Note: [ch2rs](https://github.com/ClickHouse/ch2rs) is useful to generate a row type from ClickHouse.
31
33
34
+
## Validation
35
+
36
+
Starting from 0.14.0, the crate uses `RowBinaryWithNamesAndTypes` format by default, which allows row types validation
37
+
against the ClickHouse schema. This enables clearer error messages in case of schema mismatch at the cost of
38
+
performance. Additionally, with enabled validation, the crate supports structs with correct field names and matching
39
+
types, but incorrect order of the fields, with an additional slight (5-10%) performance penalty.
40
+
41
+
If you are looking to maximize performance, you could disable validation using `Client::with_validation(false)`. When
42
+
validation is disabled, the client switches to `RowBinary` format usage instead.
43
+
44
+
The downside with plain `RowBinary` is that instead of clearer error messages, a mismatch between `Row` and database
45
+
schema will result in a `NotEnoughData` error without specific details.
46
+
47
+
However, depending on the dataset, there might be x1.1 to x3 performance improvement, but that highly depends on the
48
+
shape and volume of the dataset.
49
+
50
+
It is always recommended to measure the performance impact of validation in your specific use case. Additionally,
51
+
writing smoke tests to ensure that the row types match the ClickHouse schema is highly recommended, if you plan to
52
+
disable validation in your application.
53
+
32
54
## Usage
33
55
34
56
To use the crate, add this to your `Cargo.toml`:
57
+
35
58
```toml
36
59
[dependencies]
37
60
clickhouse = "0.13.3"
@@ -43,16 +66,6 @@ clickhouse = { version = "0.13.3", features = ["test-util"] }
43
66
<details>
44
67
<summary>
45
68
46
-
### Note about ClickHouse prior to v22.6
47
-
48
-
</summary>
49
-
50
-
CH server older than v22.6 (2022-06-16) handles `RowBinary`[incorrectly](https://github.com/ClickHouse/ClickHouse/issues/37420) in some rare cases. Use 0.11 and enable `wa-37420` feature to solve this problem. Don't use it for newer versions.
51
-
52
-
</details>
53
-
<details>
54
-
<summary>
55
-
56
69
### Create a client
57
70
58
71
</summary>
@@ -249,7 +262,8 @@ How to choose between all these features? Here are some considerations:
249
262
}
250
263
```
251
264
</details>
252
-
* `Enum(8|16)` are supported using [serde_repr](https://docs.rs/serde_repr/latest/serde_repr/).
265
+
* `Enum(8|16)` are supported using [serde_repr](https://docs.rs/serde_repr/latest/serde_repr/). You could use
266
+
`#[repr(i8)]` for `Enum8` and `#[repr(i16)]` for `Enum16`.
253
267
<details>
254
268
<summary>Example</summary>
255
269
@@ -262,7 +276,7 @@ How to choose between all these features? Here are some considerations:
Copy file name to clipboardExpand all lines: benches/README.md
+23-7Lines changed: 23 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,31 +4,41 @@ All cases are run with `cargo bench --bench <case>`.
4
4
5
5
## With a mocked server
6
6
7
-
These benchmarks are run against a mocked server, which is a simple HTTP server that responds with a fixed response. This is useful to measure the overhead of the client itself:
8
-
*`select` checks throughput of `Client::query()`.
9
-
*`insert` checks throughput of `Client::insert()` and `Client::inserter()` (if the `inserter` features is enabled).
7
+
These benchmarks are run against a mocked server, which is a simple HTTP server that responds with a fixed response.
8
+
This is useful to measure the overhead of the client itself.
9
+
10
+
### Scenarios
11
+
12
+
*[mocked_select](mocked_select.rs) checks throughput of `Client::query()`.
13
+
*[mocked_insert](mocked_insert.rs) checks throughput of `Client::insert()` and `Client::inserter()`
14
+
(requires `inserter` feature).
10
15
11
16
### How to collect perf data
12
17
13
18
The crate's code runs on the thread with the name `testee`:
0 commit comments