11

I'm designing a schema for a large Clickhouse table with string fields that can be pretty sparse.

I'm wondering if these fields should be nullable or if I should store an empty string "" as a default value. Which would be better in terms of storage?

jeffreyveon
  • 13,400
  • 18
  • 79
  • 129

1 Answers1

27

You should store an empty string ""

Nullable column takes more disk space and slowdown queries upto two times. This is an expected behaviour by design.

Inserts slowed down as well, because Nullable columns are stored in 4 files but non-Nullable only in 2 files for each column.

https://gist.github.com/den-crane/e43f8d0ad6f67ab9ffd09ea3e63d98aa

Denny Crane
  • 11,574
  • 2
  • 19
  • 30