C.4. Sequences

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

C.4.1. Are global sequences supported in Shardman?

Yes, they are supported. However, there are peculiarities of their work that should be taken into account when working with them. Under the hood of global sequences are regular sequences on each shard, and they are allocated sequential blocks (65536 numbers by default). When the numbers are handed out, the local sequential 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 (storogically speaking, it can't be broken in a simple PostgreSQL either). Well, there may be "holes" in the values given by the sequencer.

C.4.2. How to create global sequence?

CREATE SEQUENCE ... WITH (GLOBAL);
    

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

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

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