简体   繁体   English

Oracle分区性能

[英]Oracle partition performance

I have a large oracle table with more than 600 million records and we just repartitioned them so that we can purge some of the old data with out increasing the logs size. 我有一个大型的oracle表,其中包含超过6亿条记录,我们只是对其进行了重新分区,以便我们可以在不增加日志大小的情况下清除一些旧数据。

Problem is there there are some queries that does full index scan and that are run very often like 300 times per sec. 问题在于,有些查询会执行完全索引扫描,并且每秒运行300次之多。 Before partition query used to take about .15 sec but after partition its taking .50 sec to 1.25 sec. 分区之前的查询时间约为0.15秒,而分区之后的查询时间为0.50秒至1.25秒。 Does anyone know partitioning oracle table degrades the performance of the query? 有谁知道分区oracle表会降低查询性能? If yes, could you give the reason? 如果是,您能给出原因吗? There seems to be some articles but not clear enough for me to understand. 似乎有一些文章,但不够清晰,我无法理解。

If the index is local and the query is not based on the partitioning key (meaning: partition pruning is not possible) but highly selective the effort will increase in proportion to the number of partitions you create. 如果索引是本地索引,并且查询不是基于分区键的(意味着:不可能进行分区修剪),但是选择性很高,那么工作量将与您创建的分区数量成比例。 If you have 30 partitions then 30 indexes have to be searched for your values. 如果您有30个分区,则必须在30个索引中搜索您的值。 The fact that each index is smaller is not offset by the larger number of indexes. 每个索引较小的事实并不能抵消大量索引的影响。 (You might want to look at how btree indexes work to understand why this is not the case). (您可能想看看btree索引是如何工作的,以了解为什么不是这种情况)。

To cut a long story short: If you use a global index you should be able to avoid this problem. 简而言之:如果使用全局索引,则应该能够避免此问题。

When having partition table and if you are having lot of select query on this table, always include in WHERE clause Paritioncoloumn =value. 当具有分区表时,如果对该表有很多选择查询,请始终在WHERE子句中包括Paritioncoloumn = value。

example if the partition is based on column of date type (PERSISTED_DATE) 如果分区基于日期类型为(PERSISTED_DATE)的列的示例

Query 询问

SELECT * FROM TABLE_NAME WHERE COLOUMN1='VALUE' and trunc(PERSISTED_DATE)=trunc(sysdate);

Important points to note. 重要注意事项。

  1. Avoid using global index if it is high transnational table else you have to build the global index after deletion of partition. 如果它是高跨国表,请避免使用全局索引,否则您必须在删除分区后建立全局索引。
  2. For better performance keep the partition count less, you can automate creating a new partition and deletion of older partition on daily basis. 为了获得更好的性能,请减少分区数,您可以每天自动创建一个新分区并删除旧分区。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM