Oracle Partition Table Design

Source: Internet
Author: User

Partition Table Concept
Partitioning is committed to solving the key issues that support large tables and indexes. It uses a small and easy-to-manage partition-based piece (piece) method. Once a partition is defined, SQL statements can access a partition rather than the entire table, thus improving management efficiency. Partition for Data Warehouse applications Program Very effective because they often store and analyze massive amounts of historical data.

Partition Table Category
Range partitioning)
Hash partitioning (hash partition)
List partitioning (list partition)
Composite range-Hash partitioning (range-Hash combined partition)
Composite range-list partitioning (range-list combined partitions)

When to select range partitions
You must divide the table records according to the range of values in a column. You want to process some data, which is often within a certain range, such as month. If the data can be evenly distributed according to the partition range, the optimal performance will be achieved. If the data distribution is uneven, you may have to select another partitioning method.
Create Table sales
(Invoice_no number,
Sale_year int not null,
Sale_month int not null,
Sale_day int not null)
Partition by range (sale_year, sale_month, sale_day)
(Partition sales_q1 values less than (1999, 04, 01)
Tablespace TSA,
Partition sales_q2 values less than (1999, 07, 01)
Tablespace TSB,
Partition sales_q3 values less than (1999, 10, 01)
Tablespace TSC,
Partition sales_q4 values less than (2000, 01, 01)
Tablespace TSD );

When to select hash partitions
If data is not easy to use, but you want to improve performance and ease of table management. Hash partitions provide a method to evenly distribute data across a specified number of partitions. The row is mapped to the corresponding partition based on the hash value of the partition key. You can flexibly store data by creating and using hash partitions. You can use cross-Access to partition on different I/O devices to improve performance.
Create Table scubagear (ID number, name varchar2 (60 ))
Partition by hash (ID)
Partitions 4 store in (gear1, gear2, gear3, gear4 );

when to select list partitions
using list partitions, you can directly control the ing of some data to some partitions. You can specify a non-consecutive partition key value for a partition. This is different from the range partition (partition by key value range), but also from the hash partition (cannot control which partition a row is mapped ).
Create Table q1_sales_by_region
(deptno number, deptname varchar2 (20), quarterly_sales number (10, 2), State varchar2 (2 ))
partition by list (state)
(partition q1_northwest values ('or', 'wa '),
partition q1_southwest values ('az ', 'ut', 'nm '),
partition q1_northeast values ('ny', 'vm ', 'nj'),
partition q1_southeast values ('fl ', 'ga '),
partition q1_northcentral values ('sd', 'wi'),
partition q1_southcentral values ('OK', 'tx '));

Partition Table Design
how to select the partition type and partition columns? Before that, you must clarify your purpose-ease of management and performance. Which of the following aspects do you pay more attention? The impact of partition tables can be classified into the following types: performance, manageability, and data cleaning.
The following describes the specific impact of partition tables on each item.
Performance:
This is generally the main purpose of partitioning. A partition changes a large table into a small table. When the condition after where reflects the specific value of the partition field, full table scan is avoided.
ease of management:
for large tables containing massive data, the ease of management of partitions is obvious. When we recommend that you create an index based on a non-partitioned table, the only option is to create the entire index. If the table is partitioned, you can create indexes for the table in parallel based on the partition, for example:
alter index par_ind_01 reuild partition yy05;
In addition, you can also do many things at the same time, such as changing the table tablespace, exporting tables, and deleting table data.
data cleanup:
we often need to delete some historical data in the table. The general practice is Delete, however, this results in the rapid growth of Undo and redo information and affects the overall performance of the database. In this case, you can use drop partition to complete this task. For example:
alter table tab_a drop partition yy01;
when a table partition is deleted, the corresponding local index is also deleted. If a global index still exists, it will become unusable. To avoid this problem, you can use:
alter table tab_a drop partition yy01 update global indexes;

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.