Partitions
Partitioning enables you to decompose very large tables and indexes into smaller and more manageable pieces called partitions. Each partition is an independent object with its own name and
optionally its own storage characteristics.
■Increased availability
The unavailability of a partition does not entail the unavailability of the object. The query optimizer automatically removes
unreferenced partitions from the query plan so queries are not affected when the partitions are unavailable.
■Easier administration of schema objects
A partitioned object has pieces that can be managed either collectively or individually. DDL statements can manipulate partitions
rather than entire tables or indexes. Thus, you can break up resource-intensive tasks such as rebuilding an index or table. For example, you can move one table partition at a time. If a problem occurs, then only the partition move must be redone, not the table
move. Also, dropping a partition avoids executing numerous DELETE statements.
■Reduced contention for shared resources in OLTP systems
In some OLTP systems, partitions can decrease contention for a shared resource. For example, DML is distributed over many segments rather than one segment.
■Enhanced query performance in data warehouses
In a data warehouse, partitioning can speed processing of ad hoc queries. For example, a sales table containing a million rows can be partitioned by quarter.
Partition Characteristics
Each partition of a table or index must have the same logical attributes, such as column names, data types, and constraints.
For example, all partitions in a table share the same column and constraint definitions, and all partitions in an index share the same indexed columns. However, each partition can have separate physical attributes, such as the tablespace to which it belongs.
Partition Key
The partition key is a set of one or more columns that determines the partition in which each row in a partitioned table should go. Each row is unambiguously assigned to a single partition.
In the sales table, you could specify the time_id column as the key of a range partition. The database assigns rows to partitions based on whether the date in this column falls in a specified
range. Oracle Database automatically directs insert, update, and delete operations to the appropriate partition by using the partition key.
Partitioning Strategies
Oracle Partitioning offers several partitioning strategies that control how the database places data into partitions. The basic strategies are range, list, and hash partitioning.
A single-level partitioning strategy uses only one method of data distribution, for example, only list partitioning or only range partitioning. In composite partitioning, a table is partitioned
by one data distribution method and then each partition is further divided into subpartitions using a second data distribution method. For example, you could use a list partition for channel_id and a range subpartition for time_id.
Range Partitioning
In range partitioning, the database maps rows to partitions based on ranges of values of the partitioning key. Range partitioning is the most common type of partitioning and is often
used with dates.
Suppose that you want to populate a partitioned table with the sales rows shown in Example 4–1.
Example 4–2 Range-Partitioned Table
CREATE TABLE time_range_sales
( prod_id NUMBER(6)
, cust_id NUMBER
, time_id DATE
, channel_id CHAR(1)
, promo_id NUMBER(6)
, quantity_sold NUMBER(3)
, amount_sold NUMBER(10,2)
)
PARTITION BY RANGE (time_id)
(PARTITION SALES_1998 VALUES LESS THAN (TO_DATE('01-JAN-1999','DD-MON-YYYY')),
PARTITION SALES_1999 VALUES LESS THAN (TO_DATE('01-JAN-2000','DD-MON-YYYY')),
PARTITION SALES_2000 VALUES LESS THAN (TO_DATE('01-JAN-2001','DD-MON-YYYY')),
PARTITION SALES_2001 VALUES LESS THAN (MAXVALUE)
);
Afterward, you load time_range_sales with the rows from Example 4–1. Figure 4–1 shows the row distributions in the four partitions. The database chooses the partition for each row based
on the time_id value according to the rules specified in the PARTITION BY RANGE clause.
List Partitioning
In list partitioning, the database uses a list of discrete values as the partition key for each partition. You can use list partitioning to control how individual rows map to specific partitions. By using lists, you can group and organize
related sets of data when the key used to identify them is not conveniently ordered.
Assume that you create list_sales as a list-partitioned table using the statement in Example 4–3. The channel_id column is the partition key.
Example 4–3 List-Partitioned Table
CREATE TABLE list_sales
( prod_id NUMBER(6)
, cust_id NUMBER
, time_id DATE
, channel_id CHAR(1)
, promo_id NUMBER(6)
, quantity_sold NUMBER(3)
, amount_sold NUMBER(10,2)
)
PARTITION BY LIST (channel_id)
(PARTITION even_channels VALUES (2,4),
PARTITION odd_channels VALUES (3,9)
);
Afterward, you load the table with the rows from Example 4–1. Figure 4–2 shows the row distribution in the two partitions. The database chooses the partition for each row based on the channel_id value according to the rules specified in the PARTITION
BY LIST clause. Rows with a channel_id value of 2 or 4 are stored in the EVEN_CHANNELS partitions, while rows with a channel_id value of 3 or 9 are stored in the ODD_CHANNELS partition.
Hash Partitioning
In hash partitioning, the database maps rows to partitions based on a hashing algorithm that the database applies to the user-specified partitioning key. The destination of a row is determined
by the internal hash function applied to the row by the database. The hashing algorithm is designed to evenly distributes rows across devices so that each partition contains about the same number of rows.
Hash partitioning is useful for dividing large tables to increase manageability. Instead of one large table to manage, you have several smaller pieces. The loss of a single hash partition does
not affect the remaining partitions and can be recovered independently. Hash partitioning is also useful in OLTP systems with high update contention. Forexample, a segment is divided into several pieces, each of which is updated, instead of a single segment
that experiences contention.
Assume that you create the partitioned hash_sales table using the statement in Example 4–4. The prod_id column is the partition key.
CREATE TABLE hash_sales
( prod_id NUMBER(6)
, cust_id NUMBER
, time_id DATE
, channel_id CHAR(1)
, promo_id NUMBER(6)
, quantity_sold NUMBER(3)
, amount_sold NUMBER(10,2)
)
PARTITION BY HASH (prod_id)
PARTITIONS 2;
Afterward, you load the table with the rows from Example 4–1. Figure 4–3 shows a possible row distribution in the two partitions. Note that the names of these partitions are system-generated.
As you insert rows, the database attempts to randomly and evenly distribute them across partitions. You cannot specify the partition into which a row is placed. The database applies the hash function, whose outcome determines which partition contains
the row. If you change the number of partitions, then the database redistributes the data over all of the partitions.
分区表相关资料
分享到:
相关推荐
Focusing on a very active area of mathematical research in the last decade, Combinatorics of Set Partitions presents methods used in the combinatorics of pattern avoidance and pattern enumeration in ...
How_To_Resize_RAID_Partitions.pdf
poj 3782 Equal Sum Partitions.md
On convex partitions of polygonal regions
partitions Table partitions Table partitions Table
MySQL数据库分表批量主键查询代理-mysql-partitions-proxy
Permutation Partitions 题目链接-C. Permutation Partitions 题目大意 给定一个 1−n 上的全排列,将这个全排列分成不相交的 k 段,定义该划分的value为各段最大值的和,求该全排列所有可能划分中 value的最大...
如何为一个kafka集群选择topics:partitions的数量?1
2、Given five memory partitions of 100 KB, 500 KB, 200 KB, 300 KB, and 600KB (in order), how would each of the first-fit, best-fit, and worst-fit algorithms place processes of 212 KB, 417 KB, 112 KB, ...
boot: No bootable app partitions in the partition table 这里应该是分区表分配给 APP 的空间不够。借此契机来了解一下 ESP32 的分区表 partitions.csv 吧。 1. ESP32 预定义分区表 make menuconfig 配置中可...
partitions(n)返回第n个分区号,最大为Matlab最大的整数功能。 示例:partitions(0) 返回 1,partitions(200) 返回 3972999029388。 使用的算法归因于Euler,并在Mathologer的视频中描述了该算法(此代码的灵感...
gem 'partitions' 然后执行: $ bundle 或将其自己安装为: $ gem install partitions 用法 >> require 'partitions' #=> true >> 5.partitions #=> nil [1, 1, 1, 1, 1] [1, 1, 1, 2] [1, 1, 3] [1, 2, 2] [1, ...
Manage Partitions with GParted How-to
雅克比恒等式和同步分拆,季青,,雅克比恒等式是q级数中一个著名的公式,它可以从雅克比三元积恒等式导出。 它有许多的应用。比如,Ramanujan利用雅克比恒等式给出分拆�
这是一篇关于聚类融合的PPT,首次给聚类融合下了一个明确的定义。很不错哦~~
如何在POWER6或以上系统中通过IBM i逻辑分区来虚拟化支持其他的IBM i逻辑分区。
C = PARTITIONS(N),对于标量 N,返回由 {1,2,3,...N} 给出的集合的所有可能的分区。 C = PARTITIONS(N),对于向量 N,返回向量元素的分区,被视为集合的成员。 C = PARTITIONS(N),对于单元格 N,返回单元格的分区...
问题:List of all partitions: 1f00 256 mtdblock0 (driver?) 1f01 64 mtdblock1 (driver?) 1f02 2048 mtdblock2 (driver?) 1f03 63152 mtdblock3 (driver?) 1f04 65536 mtdblock4 (driver?) No filesystem ...
摘要:原创出处「朱小厮」欢迎转载,保留摘要,谢