How to Perform a FAST SPLIT PARTITION Using ALTER TABLE? (Doc ID 1268714.1)

APPLIES TO:

Oracle Database - Enterprise Edition - Version 10.2.0.3 and later
Oracle Database Cloud Schema Service - Version N/A and later
Oracle Database Exadata Express Cloud Service - Version N/A and later
Oracle Database Exadata Cloud Machine - Version N/A and later
Oracle Cloud Infrastructure - Database Service - Version N/A and later
Information in this document applies to any platform.

GOAL

The Article: [ID 378138.1] states   : Article: [ID 378138.1] pointed out:

According to the documentation:   According to the document

"Fast split partitioning takes advantage of those situations in which a split partition results in all rows being moved to a single partition. If all the rows map into a single partition and if the segment attributes of the old partition and the segment attributes of the partition inheriting all the rows match, then the database simply reuses the old segment and adds an empty segment for the other partition. Another benefit of this is that global indexes do not have to be invalidated and, in certain cases, local index partitions corresponding to the new partitions are also usable."

" Quick Split partitions using the following situations: Split partition causes all rows to move a single partition if all rows are mapped to a single partition and the old partition segment attributes segment attributes of the partition of inheritance and contents of all matching rows, database will simply reuse the old section and add a partition to another empty segment, another benefit of doing so is not necessary to make a global index is invalid, and in some cases, the local index partitions corresponding to the new partition can also be used. "

Thus, the new partitions should have the   same storage configuration as the original partition. Thus, the new partition should have the same partition as the original storage configuration.

This last statement has been the reason for   the worked example below. This last statement is the cause of working example below.

SOLUTION

NOTE: In the images and/or the document content below, the user information and data used represents fictitious data from the Oracle sample schema(s) or Public Documentation delivered with an Oracle database product. Any similarity to actual persons, living or dead, is purely coincidental and not intended in any manner.

This has been tested on 10.2.0.5 and 11.2   . It has been tested on 10.2.0.5 and 11.2.

Logon to sqlplus  

connect rk_mview/pwd

Create the partitioned table to work on.   Created to deal with the partition table

drop TABLE test;

CREATE TABLE test
( GPS_GUID RAW(16) DEFAULT (sys_guid()) NOT NULL ENABLE,
DVC_ID NUMBER(12,0) NOT NULL ENABLE,
USR_ID NUMBER(12,0) NOT NULL ENABLE,
ENTRY_UTC TIMESTAMP (6) DEFAULT (SYS_EXTRACT_UTC(SYSTIMESTAMP)) NOT NULL ENABLE,
COVERAGE_STAT_ID NUMBER(12,0) NOT NULL ENABLE,
SPEED FLOAT(126) DEFAULT (0),
DIRECTION FLOAT(126) DEFAULT (0),
ESTIMATED_ACCURACY NUMBER(12,0),
UPDATE_UTC TIMESTAMP (6) DEFAULT (SYS_EXTRACT_UTC(SYSTIMESTAMP)) NOT NULL ENABLE,
LATITUDE FLOAT(126),
LONGITUDE FLOAT(126),
TS_GUID RAW(16),
CLUSTER_ID VARCHAR2(50),
GEOCODE_UTC TIMESTAMP (6),
STREET NVARCHAR2(100),
SUITE VARCHAR2(50),
CITY NVARCHAR2(100),
STATE_PROVINCE NVARCHAR2(100),
POSTAL_CODE NVARCHAR2(20),
COUNTRY NVARCHAR2(100),
CONSTRAINT PK_GPS PRIMARY KEY (GPS_GUID)
USING INDEX PCTFREE 5 INITRANS 10 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 1M NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE users ENABLE
) PCTFREE 30 PCTUSED 0 INITRANS 10 MAXTRANS 255
STORAGE(BUFFER_POOL DEFAULT)
TABLESPACE users
PARTITION BY RANGE (ENTRY_UTC)
(PARTITION GPS_DATA_2010_08_08 VALUES LESS THAN (TIMESTAMP'2010-08-08 00:00:00')
PCTFREE 5 PCTUSED 0 INITRANS 10 MAXTRANS 255
STORAGE(INITIAL 1M NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE users NOCOMPRESS ,
PARTITION GPS_DATA_2010_08_15 VALUES LESS THAN (TIMESTAMP'2010-08-15 00:00:00')
PCTFREE 5 PCTUSED 0 INITRANS 10 MAXTRANS 255
STORAGE(INITIAL 1M NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE users NOCOMPRESS ,
PARTITION GPS_DATA_MAX VALUES LESS THAN (MAXVALUE)
PCTFREE 5 PCTUSED 0 INITRANS 10 MAXTRANS 255
STORAGE(INITIAL 1M NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE users NOCOMPRESS ) ENABLE ROW MOVEMENT;

insert into test values ('2',2,2,TIMESTAMP'2010-11-14 00:00:00',1,1,1,1,TIMESTAMP'2010-11-14 00:00:00',1,1,'1','1',TIMESTAMP'2010-11-14 00:00:00','1','1','1','1','1','1');
commit;

BEGIN
DBMS_STATS.gather_table_stats ('schema name',
'test',
partname => 'GPS_DATA_MAX',
granularity => 'PARTITION',
estimate_percent => 3,
DEGREE => 2 );
END;
/

 

In the above situation we can see that the row inserted has been added to the MAX partition, due to missing partitions.  Therefore to provide further partitions to avoid the use of the MAX partition we will need to add a partition immediately before this MAX partition.  We can use the SPLIT PARTITION syntax and this will actually perform a FAST SPLIT if all the data ends up in only one of the partitions.

In these circumstances, we can see the lack of partitions, insert rows have been added to the MAX partition. Therefore, in order to provide more partitions in order to avoid the use of MAX partition, we need to add a partition before this partition MAX immediately. We can use the SPLIT PARTITION syntax, and if all the data is ultimately located only a partition, which will actually perform the FAST SPLIT.

ON MAX Partition at The Statistics Gather to Review at The num_rows and to Optimization of Ensure A FAST SPLIT Occurs. 
- collect statistical information on the MAX partition to see num_rows and ensure FAST SPLIT optimization. 
The BEGIN 
dbms_stats.gather_table_stats ( 'Schema name', 
'Test', 
partName => 'GPS_DATA_MAX', 
granularity & => 'the PARTITION', 
estimate_percent =>. 3, 
of DEGREE => 2); 
the END; 
/

 

 
Select Queries utilized to validate the split has occurred:
--选择用于验证拆分的查询:
select FILE_ID,EXTENT_ID,BLOCK_ID from dba_extents where PARTITION_NAME='GPS_DATA_MAX';
select table_name,PARTITION_NAME, num_rows from dba_tab_partitions where table_name='TEST';

Now to run the actual split:   Now run the actual split:
.. Normally the this Note 2 by Will the Create the Data Partitions and the then the Move to the each based at The ON at The Partition boundaries the For the FAST SPLIT A new new the this by Will the Add Partition and the Leave at The A in the Data at The partition where the data fits. Note. Typically, this will create two partitions, then partition boundaries based on moving data to each partition. For FAST SPLIT, this will add a new partition, and the data retained in the data for the partition.

ALTER TABLE test SPLIT PARTITION
GPS_DATA_MAX AT ((TIMESTAMP'2010-11-28 00:00:00 +0:00'))
INTO ( PARTITION GPS_DATA_2010_11_28
LOGGING
NOCOMPRESS
TABLESPACE users
PCTFREE 5
INITRANS 10
MAXTRANS 255
STORAGE (
INITIAL 1M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
BUFFER_POOL DEFAULT
) ,
PARTITION GPS_DATA_MAX );

 

Proof the split has occurred:    occurs spli proof:

BEFORE the split:   --拆分之前:

select FILE_ID,EXTENT_ID,BLOCK_ID,PARTITION_NAME from dba_extents where segment_NAME='test';

FILE_ID EXTENT_ID BLOCK_ID PARTITION_NAME
---------- ---------- ---------- ------------------------------
4 0 27657 GPS_DATA_2010_08_08
4 0 27785 GPS_DATA_2010_08_15
4 0 27913 GPS_DATA_MAX


select table_name,PARTITION_NAME, num_rows from dba_tab_partitions where table_name='test';

TABLE_NAME PARTITION_NAME NUM_ROWS
------------------------------ ------------------------------ ----------
GPS GPS_DATA_2010_08_08
GPS GPS_DATA_2010_08_15
GPS GPS_DATA_MAX              1


AFTER the split  --拆分之后

select FILE_ID,EXTENT_ID,BLOCK_ID,PARTITION_NAME from dba_extents where segment_NAME='test';

FILE_ID EXTENT_ID BLOCK_ID PARTITION_NAME
---------- ---------- ---------- ------------------------------
4 0 27657 GPS_DATA_2010_08_08
4 0 27785 GPS_DATA_2010_08_15
4 0 27913 GPS_DATA_2010_11_28
4 0 26377 GPS_DATA_MAX

select table_name,PARTITION_NAME, num_rows from dba_tab_partitions where table_name='test';

TABLE_NAME PARTITION_NAME NUM_ROWS
------------------------------ ------------------------------ ----------
GPS GPS_DATA_2010_08_08
GPS GPS_DATA_2010_08_15
GPS GPS_DATA_MAX                0
GPS GPS_DATA_2010_11_28         1

 

So we can see from the above that the MAX partition has indeed become the new partition, and a new MAX has been added.  So a fast split has occurred.

So we can see from the above, MAX partition has indeed become a new partition, and added a new MAX. So it happened fast split.

Confirmed FAST SPLIT Syntax   confirmed FAST SPLIT grammar

ALTER TABLE test SPLIT PARTITION
GPS_DATA_MAX AT ((TIMESTAMP'2010-11-20 00:00:00 +0:00'))
INTO ( PARTITION GPS_DATA_2010_11_20
LOGGING
NOCOMPRESS
TABLESPACE users
PCTFREE 5
INITRANS 10
MAXTRANS 255 -- This is the one that works. The pctfree, initrans and maxtrans outside the storage clause.
STORAGE
(INITIAL 1M NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
BUFFER_POOL DEFAULT),
PARTITION GPS_DATA_MAX );

  

Guess you like

Origin www.cnblogs.com/zylong-sys/p/12120683.html