We are using sequence generator to generate the sequence. Ex: Every time when a row is inserted there is one more column which uses sequence to create strings like R0001, R0002 etc.
We want this sequence to be re-started for every shard. We are sharding by Org_Id which is from organisation table.
Ex: If Org Table has two entries with Ids 1,2 and Role Table has two entries with Ids 1 and 2, from Org Id 1 and Org Id 2 respectively, RoleNumbers should be R0001 and R0001 for both rows 1 and 2 in Role table. Currently since the sequence is not distributed, generated sequence is R0001 and R0002.
Is there a solution in citus for the above problem?
Distributed Sequence generation - Citus
230 Views Asked by ManojAnavatti At
1
So Citus is an extension of postgres, meaning it shares and has most of the same code as postgresql; however, it has limitiations.
Specifically, and what affects you, is that sequence generated by the node inserts its node id in front of everyone so if your node ids are 001 and 002 you would get 001R0001 and 002R0001 from my reading of it and your sequence needs to be of at least size BIGINT.
That being said, you can have two works arounds
something akin to this