use sys_guid() to instead of sequence
准备用sys_guid()来替代sequence, sys_guid or sequence column会作PK,谁能比较一下这二者的优缺点. 特别是在性能上. sys_guid在8I以后开始引入,但是应用似乎不广,因为其内容不一定符合人的习惯。SEQUENDE只能提供自开始到结束的一系列递增的值,只能保证在本INSTANCE内是唯一的,所以不符合在多INSTANCE的集成环境中,因为在数据流动中会导致冲突。
但是sys_guid是16位的ROW,比较长,所以会占用较多空间,所以可能会影响查询速度。 correct.
做了一下测试.
generate id performance: sys_guid is more quickly than sequence, sys_guid needn't access instance object(the sequence);
DML performance: sys_guid is bad than sequence when using index scan.
benefit of sys_guid: can avoid sys_guid conflict across multi-instance.
disadvantage: sql performance is a little bad than sequence, not easy to manage it, need more storage. SEQUENDE只能提供自开始到结束的一系列递增的值,只能保证在本INSTANCE内是唯一的,所以不符合在多INSTANCE的集成环境中,因为在数据流动中会导致冲突。
-------
你是说RAC不能用?我虽然没用过,不过记得似乎不是这样哦,可以指定order SEQUENDE只能提供自开始到结束的一系列递增的值,只能保证在本INSTANCE内是唯一的,所以不符合在多INSTANCE的集成环境中,因为在数据流动中会导致冲突。
上面这句话是错误的。 SEQUENCE在整个Database上唯一的,在多Instance中根据Cache值把多段sequence分配给instance。 比如: 1-20给Instance1,21-40给Instance2, 如果Instance2用完了它再取到的是41-60 Sequences—If you use sequence numbers, then always use CACHE with the
NOORDER option for optimal sequence number generation performance. With the
CACHE option, however, you may have gaps in the sequence numbers. If your
environment cannot tolerate sequence number gaps, then use the NOCACHE option
or consider pre-generating the sequence numbers. If your application requires
sequence number ordering but can tolerate gaps, then use CACHE and ORDER to
cache and order sequence numbers in RAC. If your application requires ordered
sequence numbers without gaps, then use NOCACHE and ORDER. This combination
has the most negative effect on performance compared to other caching and
ordering combinations. .
官方文档说明
页:
[1]