Home » RDBMS Server » Performance Tuning » Partitioned to Composite Partitioned
Partitioned to Composite Partitioned [message #162606] Sat, 11 March 2006 22:08 Go to next message
a_developer
Messages: 194
Registered: January 2006
Senior Member
Given a partitioned table with 100M data in it:

CREATE TABLE sample_regional_sales
      (deptno number, item_no varchar2(20),
       txn_date date, txn_amount number, state_id varchar2(2))
  PARTITION BY RANGE (txn_date)
       (PARTITION q1_1999 VALUES LESS THAN (TO_DATE('1-APR-1999','DD-MON-YYYY')),
        PARTITION q2_1999 VALUES LESS THAN ( TO_DATE('1-JUL-1999','DD-MON-YYYY')),
       PARTITION q3_1999 VALUES LESS THAN (TO_DATE('1-OCT-1999','DD-MON-YYYY')),
       PARTITION q4_1999 VALUES LESS THAN ( TO_DATE('1-JAN-2000','DD-MON-YYYY'))
      );


How do I create a subpartition by hash (state_id) with count 4?

[Updated on: Sun, 12 March 2006 06:25]

Report message to a moderator

Re: Partitioned to Composite Partitioned [message #162679 is a reply to message #162606] Mon, 13 March 2006 00:48 Go to previous messageGo to next message
rleishman
Messages: 3728
Registered: October 2005
Location: Melbourne, Australia
Senior Member
What is your reason for sub-partitioning by STATE_ID? Is it just because each partition is too big? Instead of partitioning by Quarter, why not partition by Month?

Smaller date-based partitions are more likely to be beneficial to your SQL statements that select a significant number of rows:
eg.
SELECT * 
FROM sample_regional_sales 
WHERE txn_date between TO_DATE('20050501','YYYYMMDD')
                   AND TO_DATE('20050531','YYYYMMDD')
This SQL will benefit greatly from monthly partitioning.

If you're still convinced that you want to sub-partition, take a look at the doco.

To sub-partition an existing table, the easiest way is to get your CREATE TABLE statement the way you want it (with partitions. sub-partitions, etc) and then put "AS SELECT * FROM table_name" after it. Obviously you would have to rename the old table first.
_____________
Ross Leishman
Re: Partitioned to Composite Partitioned [message #162801 is a reply to message #162679] Mon, 13 March 2006 12:45 Go to previous message
a_developer
Messages: 194
Registered: January 2006
Senior Member
thanks, Ross..

Actually, that was just an example. The real table has 35 partitions (by month as you advised) and has 40 columns. So what I gave was just to somehow show the structure..
Previous Topic: parallel hint/execution
Next Topic: Numeric or Alphanumeric datatype
Goto Forum:
  


Current Time: Sat Nov 23 14:57:42 CST 2024