Skip to content

Commit

Permalink
fix: correct create table statement (#4)
Browse files Browse the repository at this point in the history
  • Loading branch information
janzal authored Mar 22, 2024
1 parent 3f263ba commit 23ab8ea
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions pkg/targets/clickhouse/creator.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,9 @@ func createMetricsTable(conf *ClickhouseConfig, db *sqlx.DB, tableName string, f
tags_id UInt32,
%s,
additional_tags String DEFAULT ''
) ENGINE = MergeTree(created_date, (tags_id, created_at), 8192)
) ENGINE = MergeTree() PARTITION BY toYYYYMM(created_date)
ORDER BY (tags_id, created_at)
SETTINGS index_granularity = 8192;
`,
tableName,
strings.Join(columnsWithType, ","))
Expand Down Expand Up @@ -180,7 +182,9 @@ func generateTagsTableQuery(tagNames, tagTypes []string) string {
"created_at DateTime DEFAULT now(),\n"+
"id UInt32,\n"+
"%s"+
") ENGINE = MergeTree(created_date, (%s), 8192)",
") ENGINE = MergeTree() PARTITION BY toYYYYMM(created_date)"+
"ORDER BY (%s)"+
"SETTINGS index_granularity = 8192;",
cols,
index)
}
Expand Down

0 comments on commit 23ab8ea

Please sign in to comment.