Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Important and doesn't require to recreate table (can be done on existing table):
String -> LowCardinality(String)
CODEC(ZSTD(1)) -> no codec or CODEC(LZ4)
Not really important, but makes schema a bit cleaner:
-toUnixTimestamp(timestamp) -> timestamp
Probably, it can make sense to put
host
column beforepod_name
inORDER BY
, but it's needs to be tested.BTW, it's not recommended to use
.
in non-array column.Because dot reserved for Nested data type.
Using map instead of key-value arrays
It will make queries cleanier and a bit faster, eg:
But returning maps is not supported yet in clickhouse-go afaik.
ClickHouse/clickhouse-go#380
Projection optimization:
Starting from ClickHouse 21.8, we can add projections to speedup some queries:
Enable setting for using projections in queries:
But you need to write queries in following way (use
interval_data
instead oftimestamp
):Constraint optimization:
Starting from ClickHouse 21.12, it's possible to teach ClickHouse rewrite
fields_string.value[indexOf(fields_string.key, 'content.level')]
tocontent_level
column by adding constraints.In order to allow it in queries, you need to set those settings for user:
But there is one issue about them:
ClickHouse/ClickHouse#33544
But what if we don't want to actually filter by our column?
There is way to hack ClickHouse into using constraints by doing this: