When using the Memory table engine on ClickHouse Cloud, data is not replicated across all nodes (by design). To guarantee that all queries are routed to the same node and that the Memory table engine works as expected, you can do one of the following:
- Execute all operations in the same session
- Use a client that uses TCP or the native interface (which enables support for sticky connections) such as clickhouse-client
GLOBAL IN (see the section “IN operators”).
Upper and lower bounds can be specified to limit Memory engine table size, effectively allowing it to act as a circular buffer (see Engine Parameters).
Engine parameters
min_bytes_to_keep— Minimum bytes to keep when memory table is size-capped.- Default value:
0 - Requires
max_bytes_to_keep
- Default value:
max_bytes_to_keep— Maximum bytes to keep within memory table where oldest rows are deleted on each insertion (i.e circular buffer). Max bytes can exceed the stated limit if the oldest batch of rows to remove falls under themin_bytes_to_keeplimit when adding a large block.- Default value:
0
- Default value:
min_rows_to_keep— Minimum rows to keep when memory table is size-capped.- Default value:
0 - Requires
max_rows_to_keep
- Default value:
max_rows_to_keep— Maximum rows to keep within memory table where oldest rows are deleted on each insertion (i.e circular buffer). Max rows can exceed the stated limit if the oldest batch of rows to remove falls under themin_rows_to_keeplimit when adding a large block.- Default value:
0
- Default value:
compress- Whether to compress data in memory.- Default value:
false
- Default value:
Usage
Initialize settingsbytes and rows capping parameters can be set at the same time, however, the lower bounds of max and min will be adhered to.