Skip to content

Instantly share code, notes, and snippets.

@den-crane
Last active February 14, 2021 17:34
Show Gist options
  • Select an option

  • Save den-crane/2a83f4d80439aebc96739e91c872db3c to your computer and use it in GitHub Desktop.

Select an option

Save den-crane/2a83f4d80439aebc96739e91c872db3c to your computer and use it in GitHub Desktop.
String VS Array(UInt8)
create table pass (i UInt64, S String, P Array(UInt8)) Engine=MergeTree order by i;
insert into pass select number, arrayStringConcat(arrayMap(i -> char(i*number%255), range(10)),''), arrayMap(i -> i*number%255, range(30)) from numbers(10000000);
┌─database─┬─table─┬─column─┬─compressed─┬─uncompressed─┐
│ dw │ pass │ i │ 38.19 MiB │ 76.29 MiB │
│ dw │ pass │ P │ 10.30 MiB │ 362.40 MiB │
│ dw │ pass │ S │ 3.72 MiB │ 104.90 MiB │
└──────────┴───────┴────────┴────────────┴──────────────┘
clickhouse-benchmark --database default -c 16 <<< "select count() from pass where S='AAAAAA'"
QPS: 136.703
clickhouse-benchmark --database default -c 16 <<< "select count() from pass where P=[65,65,65,65,65,65]"
QPS: 70.801
--- CODEC NONE ---
create table pass (i UInt64, S String CODEC(NONE), P Array(UInt8) CODEC(NONE)) Engine=MergeTree order by i;
insert into pass select number, arrayStringConcat(arrayMap(i -> char(i*number%255), range(10)),''), arrayMap(i -> i*number%255, range(30)) from numbers(10000000);
┌─database─┬─table─┬─column─┬─compressed─┬─uncompressed─┐
│ dw │ pass │ P │ 362.45 MiB │ 362.40 MiB │
│ dw │ pass │ S │ 104.93 MiB │ 104.90 MiB │
│ dw │ pass │ i │ 20.30 MiB │ 76.29 MiB │
└──────────┴───────┴────────┴────────────┴──────────────┘
clickhouse-benchmark --database default -c 16 <<< "select count() from pass where S='AAAAAA'"
QPS: 49.017
clickhouse-benchmark --database default -c 16 <<< "select count() from pass where P=[65,65,65,65,65,65]"
QPS: 12.449
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment