Performance FixedString vs String

1,939 views
Skip to first unread message

Yegor Andreenko

unread,
Aug 30, 2016, 3:48:02 AM8/30/16
to ClickHouse
Is there any performance benefits to use FixedString(36) vs String to store UUID v4?

How does it vary with different N? N between 1 and 50 lets say.

man...@gmail.com

unread,
Aug 30, 2016, 8:48:05 PM8/30/16
to ClickHouse
UUID is 128 bit data. The most optimal way is to store it in FixedString(16) in binary form.
Remind that String and FixedString can store any binary data in ClickHouse, like BLOB, VARBINARY, BINARY in another DBMS.
(No need to waste 36 bytes for hex and hyphens.)

To show binary data, you may use hex function (but hyphens from UUIDs are lost).

In general, FixedString is more optimal than String in all cases when your strings are really fixed size.
(Otherwise, storing strings of varying size in FixedString values padded to maximum size is bad idea.)

Even for large N, for example, 50 bytes, if your strings are always 50 bytes long, better to store it in FixedString(50).
Sometimes it will lead to few percent faster queries, but in some cases up to few times.

Yegor Andreenko

unread,
Jan 23, 2017, 11:00:44 AM1/23/17
to ClickHouse
Reply all
Reply to author
Forward
0 new messages