
Unlock this content
Enter your email to unlock this content for free
Numeric Types
TL;DR
Choose the smallest integer type (UInt8 to UInt64, or Int8 to Int64) that fits your data's range to save storage and boost performance. Use Decimal for financial calculations to avoid floating-point inaccuracies, and Float for approximate values. Beware of numeric overflows.
The Numeric Types Experiment
ClickHouse offers integer types from Int8 to Int64 (signed) and UInt8 to UInt64 (unsigned). The smaller the bit size, the less storage consumed, which means better compression and faster queries.
Testing different integer sizes:
CREATE TABLE numeric_test (
num_int8 Int8,
num_int16 Int16,
num_int32 Int32,
num_int64 Int64