Oracle分区技术

Oracle分区技术

ORACLE的分区(Partitioning Option)是一种处理超大型表的技术。分区是一种“分而治之”的技术,通过将大表和索引分成可以管理的小块,从而避免了对每个表作为一个大的、单独的对象进行管理,为大量数据提供了可伸缩的性能。分区通过将操作分配给更小的存储单元,减少了需要进行管理操作的时间,并通过增强的并行处理提高了性能,通过屏蔽故障数据的分区,还增加了可用性。

ORACLE的分区表的划分方法包括:按字段值进行划分的范围分区;按字段的HASH函数值进行的划分HASH分区;先按范围划分,再按HASH划分的复合分区;在ORACLE9i中又增强了按字段值列表进行划分的列表(Listing)分区方法。
管理员可以指定每个分区的存储属性,分区在宿主文件系统中的放置情况,这样便增加了对超大型数据库的控制粒度(granularity)。分区可以被单独地删除、卸出或装入、备份、恢复,因此减少了需要进行管理操作的时间。

还可以为表分区创建单独的索引分区,从而减少了需要进行索引维护操作的时间。此外,还提供了种类繁多的局部和全局的索引技术。分区操作也可以被并行执行。
分区技术还提高了数据的可用性。当部分数据由于故障或其它原因不可用时,其它分区内的数据可用不收影响继续使用。

分区对应用是透明的,可以通过标准的SQL语句对分区表进行操作。Oracle 的优化器在访问数据时会分析数据的分区情况,在进行查询时,那些不包含任何查询数据的分区将被忽略,从而大大提高系统的性能。


分区原则

1.表分区的指南

a、表的大小
对于大表进行分区,将有益于大表操作的性能和大表的数据维护。通常当表的大小超过1.5GB-2GB,或对于OLTP系统,表的记录超过1000万,都应考虑对表进行分区。

b、数据访问特性
基于表的大部分查询应用,只访问表中少量的数据。对于这样表进行分区,可充分利用分区排除无关数据查询的特性。

c、数据维护
某些表的数据维护,经常按时间段删除成批的数据,例如按月删除历史数据。对于这样的表需要考虑进行分区,以满足维护的需要。因为删除(Delete)大量的数据,对系统开销很大,有时甚至是不可接受的。

d、只读数据
如果一个表中大部分数据都是只读数据,通过对表进行分区,可将只读数据存储在只读表空间中,对于数据库的备份是非常有益的。

e、并行数据操作(Parallel DML)
对于经常执行并行操作(如Parallel Insert,Parallel Update等)的表应考虑进行分区。

f、表的可用性
当对表的部分数据可用性要求很高时,应考虑进行表分区。


2.选择分区字段(Partition Key)

当确定分区字段时,有两个主要因素特别需要考虑:

a、增强表的管理和维护性
通过Partition Key,可以使数据维护基于某个分区进行,如Drop或Truncate一个或多个分区。通过Paratition Key可控制只读的数据存储在相应的分区中,且这些分区存储在只读的表空间里,这将提高数据备份的性能。这类Partition Key通常与时间相关。
b、提高访问表的性能
通过Partition Key,可使查询的数据定位在一个或少量的分区中;这需要考虑最常用的查询条件。注意在考虑提高查询效率这个因素的同时,还应兼顾数据维护管理的因素,尽可能地避免相互间地冲突。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
DSS queries on very large tables present special performance problems. An ad-hoc query that requires a table scan may take a long time, because it must inspect every row in the table; there is no way to identify and skip subsets of irrelevant rows. The problem is particularly important for historical tables, for which many queries concentrate access on rows that were generated recently. Partitions help solve this problem. An ad-hoc query that requires only rows that correspond to a single partition (or range of partitions) can be executed using a partition scan rather than a table scan. For example, a query that requests data generated in the month of October 1994 can scan just the rows stored in the October 1994 partition, rather than rows generated over years of activity. This improves response time. It may also substantially reduce the temporary disk space requirement for queries that require sorts. Load balancing Many DBAs want to be able to control how data is spread across physical devices. It is not sufficient to allow a table’s data to reside on multiple disks. The DBA must be able to specify where subsets of a table go, so that he can balance I/O utilization. With this level of control, the DBA can accommodate the special needs of applications requiring fast response time by reducing disk contention and utilizing faster devices. On the other hand data, that is accessed infrequently, such as old historical data, can be moved to slow disks or stored in subsystems that support a storage hierarchy. Partitioning satisfies this requirement by allowing partitions of a table or index to be stored in different tablespaces.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值