我知道序列并不能保证没有间隙,但我想尽量减少它们的发生,所以它们只会在特殊情况下发生(最好只在事务回滚时)。
我在 RAC 中有几个节点可以同时访问序列。
create sequence seq_1 start with 1 order; # this seems to return numbers without gaps, but what will happen when database is restarted? will cached elements be dropped?
create sequence seq_2 start with 1 nocache; # this one also seems to return numbers in order without gaps, but I heard some objections about using nocache as it hinders performance
create sequence seq_3 start with 1 nocache order; # any improvements over previous two?
那么哪个更好呢?
作为替代方案,我可以使用表来存储序列号,但目前我想考虑基于序列的解决方案而不是基于表的解决方案。
谢谢。