1
CREATE TABLE optimized_select_final (t DateTime, x Int32, s String)
ENGINE = ReplacingMergeTree()
PARTITION BY toYYYYMM(t) ORDER BY x
INSERT INTO optimized_select_final SELECT toDate('2020-01-01'), number, 'string' FROM numbers(50000000)
OPTIMIZE TABLE optimized_select_final FINAL
SELECT * FROM optimized_select_final FINAL where s = 'string' FORMAT Null
DROP TABLE IF EXISTS optimized_select_final