Merge pull request #60052 from ClickHouse/docs-cloud-insert-tip

[Docs] Add info on using select_sequential_consistency for INSERTS in…
This commit is contained in:
Alexey Milovidov 2024-02-17 03:18:40 +01:00 committed by GitHub
commit 3ebea51d53
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -204,6 +204,20 @@ Result:
└─────┴───────────────────────┘ └─────┴───────────────────────┘
``` ```
## Inserts into ClickHouse Cloud
By default, services on ClickHouse Cloud provide multiple replicas for high availability. When you connect to a service, a connection is established to one of these replicas.
After an `INSERT` succeeds, data is written to the underlying storage. However, it may take some time for replicas to receive these updates. Therefore, if you use a different connection that executes a `SELECT` query on one of these other replicas, the updated data may not yet be reflected.
It is possible to use the `select_sequential_consistency` to force the replica to receive the latest updates. Here is an example of a SELECT query using this setting:
```sql
SELECT .... SETTINGS select_sequential_consistency = 1;
```
Note that using `select_sequential_consistency` will increase the load on ClickHouse Keeper (used by ClickHouse Cloud internally) and may result in slower performance depending on the load on the service. We recommend against enabling this setting unless necessary. The recommended approach is to execute read/writes in the same session or to use a client driver that uses the native protocol (and thus supports sticky connections).
## Performance Considerations ## Performance Considerations
`INSERT` sorts the input data by primary key and splits them into partitions by a partition key. If you insert data into several partitions at once, it can significantly reduce the performance of the `INSERT` query. To avoid this: `INSERT` sorts the input data by primary key and splits them into partitions by a partition key. If you insert data into several partitions at once, it can significantly reduce the performance of the `INSERT` query. To avoid this: