about me:oracle ace pro,optimistic,passionate and harmonious. focus on oracle,mysql and other database programming,peformance tuning,db design, j2ee,linux/aix,architecture tech,etc
全部博文(166)
分类: oracle
2023-05-06 14:23:43
从oracle 18.1数据库开始,自适应序列 (scalable sequences) 被引入。
为了改善以序列值作为键值的表的数据加载性能,自适应序列的特性被加入。这个特性为序列提供了添加 instance 和 session 偏移量的选项,当跨 rac节 点加载数据或者单实例多个进程并发加载数据时,可以显著减少序列争用和索引块争用的可能性,以前可以应用自定义主键为类似scalable sequences来解决,经常用hash partition index解决,但是只能等值查询,也不能从根本上解决。
这个新特性的好处是,在以序列作为键值的表的数据加载时,它通过减少争用来进一步提升oracle数据库加载数据的能力。在创建序列的时候,将 instance 和 session 的 id 添加到序列的值中,这样在生成序列值时产生的争用和 insert 键值时产生的索引块争用可以显著的减少。这表明oracle数据库数据的数据加载能力可以进一步扩展,并且可以支撑更高速率的数据加载。
scalable sequences:
create | alter sequence [ schema. ]sequence
[ { increment by | start with } integer
| { maxvalue integer | nomaxvalue }
| { minvalue integer | nominvalue }
| { cycle | nocycle }
| { cache integer | nocache }
| { order | noorder }
| { scale {extend | noextend} | noscale}
]
scale/noscale
when scale is specified, a numeric offset is affixed to the beginning of the sequence. this offset if of the form iii||sss||, where,
iii denotes a three digit instance offset given by (instance_id % 100) 100,
sss denotes a three digits session offset given by (session_id % 1000), and
|| is the concatenation operator
extend/noextend
为scale子句指定extend选项时,scale序列值的长度为[x位 y位],其中x是可缩放序列偏移量中的位数(默认为6位),y是maxvalue子句中指定的位数。
例如,对于指定了minvalue为1、maxvalue为100(3位)和extend选项的升序可扩展序列,可扩展序列值将为9位(6位可扩展序列偏移号 3位maxvalue),并且将采用以下形式:
iii||sss||001, iii||sss||002, …,iii||sss||100
6 digit scalable sequence offset number || 001 6 digit scalable sequence offset number || 002 6 digit scalable sequence offset number || 003 ... 6 digit scalable sequence offset number || 100
6 digit scalable sequence offset number || 1 6 digit scalable sequence offset number || 2 6 digit scalable sequence offset number || 3 ... 6 digit scalable sequence offset number || 9note that the nextval operation on this scalable sequence after the sequence value of [6 digit scalable sequence offset number || 9] will report the following error message, because the next scalable sequence value is [6 digit scalable sequence offset number || 10], which contains 8 digits and is greater than maxvalue of 1000000 that contains 7 digits:
ora-64603: nextval cannot be instantiated for sq. widen the sequence by 1 digits or alter sequence with scale extend.
上一篇:
下一篇: