未验证 提交 ac05c6f2 编写于 作者: A alexey-milovidov 提交者: GitHub

Merge pull request #1902 from kshvakov/master

Использование произвольного ключа партиционирования для таблицы лога запросов
......@@ -1423,13 +1423,15 @@ QueryLog & Context::getQueryLog()
auto & config = getConfigRef();
String database = config.getString("query_log.database", "system");
String table = config.getString("query_log.table", "query_log");
String database = config.getString("query_log.database", "system");
String table = config.getString("query_log.table", "query_log");
String partition_by = config.getString("query_log.partition_by", "toYYYYMM(event_date)");
size_t flush_interval_milliseconds = config.getUInt64(
"query_log.flush_interval_milliseconds", DEFAULT_QUERY_LOG_FLUSH_INTERVAL_MILLISECONDS);
String engine = "ENGINE = MergeTree PARTITION BY (" + partition_by + ") ORDER BY (event_date, event_time) SETTINGS index_granularity = 1024";
system_logs->query_log = std::make_unique<QueryLog>(
*global_context, database, table, "ENGINE = MergeTree(event_date, event_time, 1024)", flush_interval_milliseconds);
system_logs->query_log = std::make_unique<QueryLog>(*global_context, database, table, engine, flush_interval_milliseconds);
}
return *system_logs->query_log;
......
......@@ -226,7 +226,15 @@
-->
<database>system</database>
<table>query_log</table>
<!--
PARTITION BY expr https://clickhouse.yandex/docs/en/table_engines/custom_partitioning_key.html
Example:
event_date
toMonday(event_date)
toYYYYMM(event_date)
toStartOfHour(event_time)
-->
<partition_by>toYYYYMM(event_date)</partition_by>
<!-- Interval of flushing data. -->
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
</query_log>
......
......@@ -518,6 +518,7 @@ Use the following parameters to configure logging:
- database – Name of the database.
- table – Name of the table.
- partition_by - Sets the [custom partition key](../../table_engines/custom_partitioning_key.md#custom-partitioning-key).
- flush_interval_milliseconds – Interval for flushing data from memory to the disk.
**Example**
......@@ -526,6 +527,7 @@ Use the following parameters to configure logging:
<part_log>
<database>system</database>
<table>part_log</table>
<partition_by>toMonday(event_date)</partition_by>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
</part_log>
```
......@@ -560,6 +562,7 @@ Use the following parameters to configure logging:
- database – Name of the database.
- table – Name of the table.
- partition_by - Sets the [custom partition key](../../table_engines/custom_partitioning_key.md#custom-partitioning-key).
- flush_interval_milliseconds – Interval for flushing data from memory to the disk.
If the table doesn't exist, ClickHouse will create it. If the structure of the query log changed when the ClickHouse server was updated, the table with the old structure is renamed, and a new table is created automatically.
......@@ -570,6 +573,7 @@ If the table doesn't exist, ClickHouse will create it. If the structure of the q
<query_log>
<database>system</database>
<table>query_log</table>
<partition_by>toMonday(event_date)</partition_by>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
</query_log>
```
......
......@@ -520,6 +520,7 @@ ClickHouse проверит условия `min_part_size` и `min_part_size_rat
- database - Имя базы данных.
- table - Имя таблицы.
- partition_by - Устанавливает [произвольный ключ партиционирования](../../table_engines/custom_partitioning_key.md#custom-partitioning-key).
- flush_interval_milliseconds - Период сброса данных из оперативной памяти на диск.
......@@ -529,6 +530,7 @@ ClickHouse проверит условия `min_part_size` и `min_part_size_rat
<part_log>
<database>system</database>
<table>part_log</table>
<partition_by>toMonday(event_date)</partition_by>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
</part_log>
```
......@@ -563,6 +565,7 @@ ClickHouse проверит условия `min_part_size` и `min_part_size_rat
- database - Имя базы данных.
- table - Имя таблицы.
- partition_by - Устанавливает [произвольный ключ партиционирования](../../table_engines/custom_partitioning_key.md#custom-partitioning-key).
- flush_interval_milliseconds - Период сброса данных из оперативной памяти на диск.
Если таблица не существует, то ClickHouse создаст её. Если структура журнала запросов изменилась при обновлении сервера ClickHouse, то таблица со старой структурой переименовывается, а новая таблица создается автоматически.
......@@ -573,6 +576,7 @@ ClickHouse проверит условия `min_part_size` и `min_part_size_rat
<query_log>
<database>system</database>
<table>query_log</table>
<partition_by>toMonday(event_date)</partition_by>
<flush_interval_milliseconds>7500</flush_interval_milliseconds>
</query_log>
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册