v.24.7Improvement

Function generateSnowflakeID Now Accepts Machine ID Parameter to Prevent Collisions

Function generateSnowflakeID now allows to specify a machine ID as a parameter to prevent collisions in large clusters. #66374 (ZAWA_ll).
The generateSnowflakeID function now supports an optional machine ID parameter to help prevent ID collisions in large distributed ClickHouse clusters.

Why it matters

This feature addresses the risk of unique identifier collisions when generating Snowflake IDs across many nodes by allowing users to specify a machine ID. It improves the reliability and uniqueness of generated IDs in large-scale deployments.

How to use it

Use the generateSnowflakeID function with the machine ID as an additional argument. For example:

SELECT generateSnowflakeID(machine_id)

where machine_id is an integer representing the unique identifier of the machine or node.