Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 14 additions & 8 deletions pkg/targets/clickhouse/creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,16 @@ func createMetricsTable(conf *ClickhouseConfig, db *sqlx.DB, tableName string, f

sql := fmt.Sprintf(`
CREATE TABLE %s (
created_date Date DEFAULT today(),
created_at DateTime DEFAULT now(),
time String,
tags_id UInt32,
%s,
additional_tags String DEFAULT ''
) ENGINE = MergeTree(created_date, (tags_id, created_at), 8192)
created_date Date DEFAULT today(),
created_at DateTime DEFAULT now(),
time String,
tags_id UInt32,
%s,
additional_tags String DEFAULT ''
) ENGINE = MergeTree()
ORDER BY (tags_id, created_at)
PARTITION BY created_date
SETTINGS index_granularity = 8192
`,
tableName,
strings.Join(columnsWithType, ","))
Expand Down Expand Up @@ -180,7 +183,10 @@ func generateTagsTableQuery(tagNames, tagTypes []string) string {
"created_at DateTime DEFAULT now(),\n"+
"id UInt32,\n"+
"%s"+
") ENGINE = MergeTree(created_date, (%s), 8192)",
") ENGINE = MergeTree()\n"+
"PARTITION BY created_date\n"+
"ORDER BY (%s)\n"+
"SETTINGS index_granularity = 8192",
cols,
index)
}
Expand Down
Loading