What is the maximum length of a column in clickhouse? Can it be modified?

Viewed 1224

For example, the maximum length of a column in Postgres is 63 characters (as mentioned in its official documentation), similarly what is the maximum column length of a clickhouse table and if it possible to change it, how?

1 Answers

In PostgreSQL, identifiers — table names, column names, constraint names, etc. — are limited to a maximum length of 63 bytes.

Clickhouse does not have own limits on identifiers length. But you're limited by a filesystems' limits, because CH uses filenames as table/column names.

Ext4 max filename length -- ext4 255 bytes. And a maximum path of 4096 characters.

https://serverfault.com/questions/9546/filename-length-limits-on-linux

The problem is that CH encodes filenames using url-encode.

create table "ляля"("тест" Int64) Engine = MergeTree order by tuple();
insert into "ляля" values(1);

/var/lib/clickhouse/data/dw/%D0%BB%D1%8F%D0%BB%D1%8F/

in this case 4 cyrillic characters were stored as 24 bytes.

This causes various issues like this

DB::ErrnoException: Cannot open file /var/lib/clickhouse/data/goSNynThCyuHpAZGJwCC/%D0%92%D1%8B%D0%B3%D1%80%D1%83%D0%B7%D0%BA%D0%B0%20%D0%B4%D0%BB%D1%8F%20%D0%B4%D0%B0%D1%88%D0%B1%D0%BE%D1%80%D0%B4%D0%B8%D0%BD%D0%B3%D0%B0%2Etxt%281%29/tmp_insert_all_1_1_0/%D0%92%D1%8B%D0%B3%D1%80%D1%83%D0%B7%D0%BA%D0%B0%20%D0%B4%D0%BB%D1%8F%20%D0%B4%D0%B0%D1%88%D0%B1%D0%BE%D1%80%D0%B4%D0%B8%D0%BD%D0%B3%D0%B0%2Etxt%2E%D0%A0%D0%B5%D0%B3%D0%B8%D0%BE%D0%BD%D0%B0%D0%BB%D1%8C%D0%BD%D1%8B%D0%B9%20%D1%84%D0%B8%D0%BB%D0%B8%D0%B0%D0%BB.bin, errno: 36, strerror: File name too long

So, I suggest to keep identifiers as short as possible and use only Latin characters.

Related