|
本帖最后由 Yong Huang 于 2015-3-2 10:39 编辑
> 如果有高并发,那么他的主键索引单向增长问题才会比较突出,RAC下可能会放大(因为还会涉及不同节点间争用同一个索引块的消耗)
The part in your parenthesis may not be true if you allocate different ranges of sequence values in different RAC nodes, or concatenate instance ID with sequence (just these two components).
Another trick people use on RAC is to partition the applications in functionality. For example, if your RAC database is the backend for multiple applications, use service to limit one application to connect to one RAC instance, another application to another instance. By limit, I mean set the preferred instance. You still allow the other instance to serve as a failover (called "available") instance. Alternatively, use one RAC instance for DML and the other for mostly queries. Partitioning applications is a general strategy, not specific to sequences.
> 做一种复合主键,打散单向增长的索引
In the real world, if a table has a high insert rate, the table probably uses a single column surrogate (meaningless, usually sequence-based) key, not a natural key. I don't recall seeing anybody using a composite key for a major table with high concurrent insert rate. I have a feeling that the overhead of dealing with the multiple columns of the key, compared with the simple single column, outweighs the benefit, if any, of reducing the contention. If any shop does that, I'd like to hear. In practice, check enqueue contention on SQ. If it's indeed high, do these in order: (1) make sure its cache is high and order is NOT specified, (2) allocate separate ranges to nodes, (3) partition the applications (see above), (4) prefix sequence with instance ID to be used as PK, (5) something more complicated. |
|