Oracle 中的全局非分区索引
Global nonpartitioned index in Oracle
我正在阅读有关 Oracle 分区索引的文档。到处都可以找到本地分区索引和全局分区索引之间的区别,这对我来说很清楚。
我很困惑 'global' 这个词根本不表示索引是分区的。
例如Thomas Kyte 在 'Expert Oracle Database Architecture' 中有几个这样的例子:
create index partitioned_idx_global
on partitioned(timestamp)
GLOBAL;
Index created.
并且可以在其他地方找到类似的示例,其中关键字 GLOBAL 后面没有跟任何分区描述。
GLOBAL 后没有分区子句,这似乎与 CREATE INDEX docs 中允许的相反。
documentation for nonpartitioned global indexes 对我来说也没有多大意义。
Global nonpartitioned indexes behave just like local nonpartitioned indexes.
'local nonpartitioned index'到底是什么?它甚至不应该存在。
所以最终我的问题是消除混淆。常规索引和全局非分区索引有什么区别?上面书里引用的语法是不是连'legal'?
What the heck is 'local nonpartitioned index'?
没有"local nonpartitioned index"。似乎这可能是一个文档错误。我认为他们的意思是
"Global nonpartitioned indexes behave just like indexes on nonpartitioned tables."
是的,Tom Kyte 书中引用的语法是合法的。
There is no partitioning clause after GLOBAL which seems to be in contrast to what is allowed in CREATE INDEX docs
默认情况下,GLOBAL 索引是非分区的。即table的所有分区都有一个索引。我们可能想要这样做的主要原因是在整个 table 中强制执行唯一约束。在实践中,很少需要这样做:分区通常仅限于数据仓库,其中的约束执行通常比较宽松,因为 DML 更加锁定。
您链接到的文档显示了如何创建 GLOBAL 分区索引。这是一种混合结构,它允许我们使用与用于分区数据的分区方案不同的分区方案来构建索引。老实说,我从来没有在我使用过分区的任何站点上遇到过这种情况。但是,@matthewmcpeak 提出了一个可能有用的场景。因此,为了未来的搜索者的利益,我将他的评论包含在这个答案中。
A global hash partitioned index is a good way to reduce contention on very active, unique indexes of sequence values. Normally, all inserts are on the right side of the index. If there are many inserts from many parallel sessions, there can be a lot of contention -- with each session causing more work for the others (since they'll all need to apply a lot of UNDO to backout committed changes to get consistent block reads). An old solution to this was to use a REVERSE
index. Now, a global hash partitioned index is better -- reduces contention without blowing up physical I/Os.
The table itself does not need to be partitioned for the technique to apply.
Oracle原则上提供三种类型的索引。
- 全局非分区索引:你有一个跨越table的所有分区的索引。如果您更改 table 分区,则此类索引将变为
UNUSABLE
,您必须重建它。
- Local Partitioned Indexes:该索引的分区方式与基础分区相同table。每个索引分区仅属于一个 table 分区。
- Global Partitioned Indexes:这个索引是分区的,但是分区键和base table的分区键不同(也可以是非分区的table).例如,您可以让 table 不分区或按 RANGE 分区,但索引按不同列的 LIST 分区。
最常见的是全局非分区和本地分区索引。实际上,我无法想象 全局分区 索引有意义的任何用例,它们可能仅在非常特殊的情况下才有用。
我正在阅读有关 Oracle 分区索引的文档。到处都可以找到本地分区索引和全局分区索引之间的区别,这对我来说很清楚。
我很困惑 'global' 这个词根本不表示索引是分区的。
例如Thomas Kyte 在 'Expert Oracle Database Architecture' 中有几个这样的例子:
create index partitioned_idx_global
on partitioned(timestamp)
GLOBAL;
Index created.
并且可以在其他地方找到类似的示例,其中关键字 GLOBAL 后面没有跟任何分区描述。
GLOBAL 后没有分区子句,这似乎与 CREATE INDEX docs 中允许的相反。
documentation for nonpartitioned global indexes 对我来说也没有多大意义。
Global nonpartitioned indexes behave just like local nonpartitioned indexes.
'local nonpartitioned index'到底是什么?它甚至不应该存在。
所以最终我的问题是消除混淆。常规索引和全局非分区索引有什么区别?上面书里引用的语法是不是连'legal'?
What the heck is 'local nonpartitioned index'?
没有"local nonpartitioned index"。似乎这可能是一个文档错误。我认为他们的意思是
"Global nonpartitioned indexes behave just like indexes on nonpartitioned tables."
是的,Tom Kyte 书中引用的语法是合法的。
There is no partitioning clause after GLOBAL which seems to be in contrast to what is allowed in CREATE INDEX docs
默认情况下,GLOBAL 索引是非分区的。即table的所有分区都有一个索引。我们可能想要这样做的主要原因是在整个 table 中强制执行唯一约束。在实践中,很少需要这样做:分区通常仅限于数据仓库,其中的约束执行通常比较宽松,因为 DML 更加锁定。
您链接到的文档显示了如何创建 GLOBAL 分区索引。这是一种混合结构,它允许我们使用与用于分区数据的分区方案不同的分区方案来构建索引。老实说,我从来没有在我使用过分区的任何站点上遇到过这种情况。但是,@matthewmcpeak 提出了一个可能有用的场景。因此,为了未来的搜索者的利益,我将他的评论包含在这个答案中。
A global hash partitioned index is a good way to reduce contention on very active, unique indexes of sequence values. Normally, all inserts are on the right side of the index. If there are many inserts from many parallel sessions, there can be a lot of contention -- with each session causing more work for the others (since they'll all need to apply a lot of UNDO to backout committed changes to get consistent block reads). An old solution to this was to use a
REVERSE
index. Now, a global hash partitioned index is better -- reduces contention without blowing up physical I/Os. The table itself does not need to be partitioned for the technique to apply.
Oracle原则上提供三种类型的索引。
- 全局非分区索引:你有一个跨越table的所有分区的索引。如果您更改 table 分区,则此类索引将变为
UNUSABLE
,您必须重建它。 - Local Partitioned Indexes:该索引的分区方式与基础分区相同table。每个索引分区仅属于一个 table 分区。
- Global Partitioned Indexes:这个索引是分区的,但是分区键和base table的分区键不同(也可以是非分区的table).例如,您可以让 table 不分区或按 RANGE 分区,但索引按不同列的 LIST 分区。
最常见的是全局非分区和本地分区索引。实际上,我无法想象 全局分区 索引有意义的任何用例,它们可能仅在非常特殊的情况下才有用。