C.4. Sequences

C.4.1. Are global sequences supported in Shardman?
C.4.2. How to create a global sequence?

C.4.1. Are global sequences supported in Shardman?

Yes, they are supported. However, there are specifics of their work that should be taken into account. Under the hood of global sequences, there are regular sequences on each shard, and they are allocated by sequential blocks (of 65536 numbers by default). When numbers are passed to the sequence, the local sequential block is given to the local sequential block on the shard. I.e., numbers from the global sequences are unique, but there is no strict monotony (unlike in PostgreSQL). Well, there may be "holes" in the values given by the sequencer.

C.4.2. How to create a global sequence?

CREATE SEQUENCE ... WITH (GLOBAL);
    

Note that the shardman.next_value function should be used to fetch the next value of a sequence:

SELECT shardman.next_value('acl_id_seq'::regclass); 
    

We will fix this in future versions, and a normal fetch will also work correctly. Data type bigserial (for automatic creation of sequences and output of default values from it) is implemented and works for both sharded and global tables. We recommend using bigserial unless you have some special requirements.