1BRC in ClickHouse SQL (<7.5 Seconds) #80
YunfanZhang42
started this conversation in
Show and tell
Replies: 4 comments 1 reply
-
Awsome. Really like, how concise and readable this is! |
Beta Was this translation helpful? Give feedback.
0 replies
-
For more complete picture you can also show if approach without Memory table works faster or slower on your hardware:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
@qoega I ran the query without the memory table and it seems the query indeed became faster. I am getting around 6.7s on a hot run so there is a small improvement. Maybe ClickHouse has different query plans if the data do not need to persist? -- Change to your number of physical CPU threads for the best performance.
SET max_insert_threads = 28;
SET max_threads = 28;
SET format_csv_delimiter = ';';
SELECT
concat('{', arrayStringConcat(groupArray(formatted_result), ', '), '}') AS final_output
FROM (
SELECT
format('{}={}/{}/{}', location, toDecimalString(min(temperature), 1), toDecimalString(avg(temperature), 1), toDecimalString(max(temperature), 1)) AS formatted_result
FROM file('measurements.txt', 'CSV', 'location String, temperature Float32')
GROUP BY location
ORDER BY location
) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Did not check the exact output format, but should be close. Finishes at 7.192s on my i7-14700K + 64GB RAM machine on a hot run, while the baseline Java solution takes ~90s. Most of the time is spent on ingesting the text file. Contributions and fixes welcome!
Beta Was this translation helpful? Give feedback.
All reactions