@@ -137,13 +137,16 @@ func createMetricsTable(conf *ClickhouseConfig, db *sqlx.DB, tableName string, f
137137
138138 sql := fmt .Sprintf (`
139139 CREATE TABLE %s (
140- created_date Date DEFAULT today(),
141- created_at DateTime DEFAULT now(),
142- time String,
143- tags_id UInt32,
144- %s,
145- additional_tags String DEFAULT ''
146- ) ENGINE = MergeTree(created_date, (tags_id, created_at), 8192)
140+ created_date Date DEFAULT today(),
141+ created_at DateTime DEFAULT now(),
142+ time String,
143+ tags_id UInt32,
144+ %s,
145+ additional_tags String DEFAULT ''
146+ ) ENGINE = MergeTree()
147+ ORDER BY (tags_id, created_at)
148+ PARTITION BY created_date
149+ SETTINGS index_granularity = 8192
147150 ` ,
148151 tableName ,
149152 strings .Join (columnsWithType , "," ))
@@ -180,7 +183,10 @@ func generateTagsTableQuery(tagNames, tagTypes []string) string {
180183 "created_at DateTime DEFAULT now(),\n " +
181184 "id UInt32,\n " +
182185 "%s" +
183- ") ENGINE = MergeTree(created_date, (%s), 8192)" ,
186+ ") ENGINE = MergeTree()\n " +
187+ "PARTITION BY created_date\n " +
188+ "ORDER BY (%s)\n " +
189+ "SETTINGS index_granularity = 8192" ,
184190 cols ,
185191 index )
186192}
0 commit comments