简体   繁体   English

Oracle 12c-对于具有分区和子分区的表,应使用哪个索引

[英]Oracle 12c - which index should be used for a table with partitions and sub-partitions

I have a table of 500M records in Oracle 12c. 我在Oracle 12c中有一张500M记录的表。 Table is partitioned per 1 varchar column and sub-partitioned per other varchar column. 表按1个varchar列进行分区,并按其他varchar列进行子分区。

What indexes should be used with queries that use these 2 columns in Where clause? 在Where子句中使用这两列的查询应使用哪些索引?

I am assuming local partitioned indexes are the best choice but wanted to get more insight on when is this a case and how is the best to create them? 我假设本地分区索引是最佳选择,但想了解何时出现这种情况以及如何最好地创建它们?

Oracle is capable of partition pruning , meaning that if your query has the partition key column(s) in the where clause, Oracle is smart enough to only query those partitions that are relevant. Oracle能够进行分区修剪 ,这意味着,如果您的查询在where子句中具有分区键列,则Oracle足够聪明,只查询相关的那些分区。 In such case a local partitioned index is more beneficial because it is "local to the partition", ie the index is also partitioned the same way and Oracle will only read the relevant index entries for those partition that are relevant. 在这种情况下, 本地分区索引会更有利,因为它是“分区本地的”,即索引也以相同的方式分区,并且Oracle将只读取与该分区相关的相关索引条目。

If however you have a query that doesn't have the partition key column(s) in the where clause Oracle can't apply partition pruning and will have no other choice but to scan all local partitioned indexes or, worst case, the entire table for the data. 但是,如果查询的where子句中没有分区键列,那么Oracle将无法应用分区修剪,并且除了扫描所有本地分区索引 (最坏的情况是扫描整个表)之外别无选择用于数据。 This is where a global partitioned index will come in handy on those columns that are in the where clause. 在这里,全局分区索引将在where子句中的那些列上派上用场。 In that case Oracle creates an index over those columns across partitions and knows exactly which records to read from which partitions that qualify for the where clause of the statement. 在那种情况下,Oracle在分区中的这些列上创建索引,并确切知道要从哪些分区中读取哪些记录符合该语句的where子句。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Oracle 12c - 如何查看某个表的所有分区和子分区以及每个表的记录数 - Oracle 12c - how to see all partitions and sub-partitions for some table and number of records for each Oracle 12c - 如何使用列表分区自动创建新分区 - Oracle 12c - how to create new partitions automatically with list partitions 在Greenplum中删除或截断子分区 - Drop or truncate sub-partitions in Greenplum Oracle 12c-如何使用现有表(如第一个表)创建一个包含所有数据,分区和索引的新表? - Oracle 12c - how to create a new table form existing table with all data, partitions and indexes like in first table? SQL over子句 - 将分区划分为编号的子分区 - SQL over clause - dividing partition into numbered sub-partitions 更改表 SQL Oracle - 12c - ALTER TABLE SQL Oracle - 12c JPA还是使用Oracle表分区休眠? - JPA or Hibernates With Oracle Table Partitions? ORACLE 12c唯一约束在MERGE命令中失败,该命令与索引中的所有列匹配 - ORACLE 12c Unique constraint failing in MERGE command which is matching all columns from the index 使用alter命令在Oracle中进行表分区 - Table partitions in oracle with alter command Oracle 12c:我可以从同时获取和返回表的WITH子句中调用函数吗? - Oracle 12c: Can I invoke a function from a WITH clause which both takes and returns a table?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM