The scheduler uses a tuple(now64(),rowNumberInAllBlocks) to build a unique ID for coming events.
It's UInt64+UInt32. It could be done better by using SnowFlakeId (Int64). 22 bits is enough for operating 4M row blocks. for 1M blocks, we have space for 4 different cluster nodes.
create function toSnowflake64 as (dt,ch) ->
bitOr(dateTime64ToSnowflake(dt),
bitAnd(bitAnd(ch,0x3FFFFF)+
bitAnd(bitShiftRight(ch, 20),0x3FFFFF)+
bitAnd(bitShiftRight(ch, 40),0x3FFFFF),
0x3FFFFF)
);
with rowNumberInAllBlocks() as rn,
now64() as dt
SELECT hex(toSnowflake64(dt,rn) as sn),
snowflakeToDateTime64(sn)
from numbers(10);
The scheduler uses a tuple(now64(),rowNumberInAllBlocks) to build a unique ID for coming events. It's UInt64+UInt32. It could be done better by using SnowFlakeId (Int64). 22 bits is enough for operating 4M row blocks. for 1M blocks, we have space for 4 different cluster nodes.