
Unlock this content
Enter your email to unlock this content for free
IPv4, IPv6
TL;DR
Use ClickHouse's native IPv4 and IPv6 types for efficient storage, validation, and manipulation of IP addresses. They store addresses as compact integers, saving 50-70% storage compared to strings.
IP Address Types
ClickHouse provides IPv4 and IPv6 types optimized for IP addresses. Benefits: compact storage (IPv4 as UInt32/4 bytes, IPv6 as FixedString(16)/16 bytes), automatic validation, and native IP functions.
Using IP Types
IPv4: Stored as UInt32 (4 bytes). Use for IPv4 addresses.
IPv6: Stored as FixedString(16) (16 bytes). Use for IPv6 addresses.
CREATE TABLE access_logs (