Presentation is loading. Please wait.

Presentation is loading. Please wait.

© 2010 IBM Corporation September 9, 2010 IDS 11.7 – New Fragmentation Strategies Scott Pickett – WW Informix Technical Sales For questions about this presentation.

Similar presentations


Presentation on theme: "© 2010 IBM Corporation September 9, 2010 IDS 11.7 – New Fragmentation Strategies Scott Pickett – WW Informix Technical Sales For questions about this presentation."— Presentation transcript:

1 © 2010 IBM Corporation September 9, 2010 IDS 11.7 – New Fragmentation Strategies Scott Pickett – WW Informix Technical Sales For questions about this presentation contact: spickett@us.ibm.comspickett@us.ibm.com

2 © 2010 IBM Corporation 2  List / Interval Fragmentation Strategies.  OAT - List / Interval Fragmentation Strategies.  ALTER FRAGMENT support.  ALTER FRAGMENT ONLINE support. ALTER FRAGMENT Support Agenda

3 © 2010 IBM Corporation September 9, 2010 List / Interval Fragmentation Strategies

4 © 2010 IBM Corporation 4 Fragmentation (or Partitioning)  Allows data from a single table to be stored on multiple disks.  Non-fragmented table: CREATE TABLE tab1 (i INT); CREATE TABLE tab2 (i INT) IN dbs0;  Fragmented table: CREATE TABLE tab3 (i INT) FRAGMENT BY ROUND ROBIN IN dbs1, dbs2; CREATE TABLE tab4 (i INT) FRAGMENT BY EXPRESSION (i = 100 AND i < 200) IN dbs2, REMAINDER IN dbs3;

5 © 2010 IBM Corporation 5 List Fragmentation Strategy  Fragments data based on a list of discrete values: –States in a country or departments in an organization.

6 © 2010 IBM Corporation 6 List Fragmentation CREATE TABLE customer (id SERIAL, fname CHAR(32), lname CHAR(32), state Char(2), phone CHAR(12)) FRAGMENT BY LIST (state) PARTITION p0 VALUES ("KS", "IL") IN dbs0, PARTITION p1 VALUES ("CA", "OR") IN dbs1, PARTITION p2 VALUES ("NY", "MN") IN dbs2, PARTITION p3 VALUES (NULL) IN dbs3, PARTITION p4 REMAINDER IN dbs3;  The table is fragmented on the column “state” – also known as the fragment or partitioning key.  The fragment key can be a column expression: – FRAGMENT BY LIST (SUBSTR(phone, 1, 3))  The fragment key expression can have multiple columns: – FRAGMENT BY LIST (fname[1,1] || lname[1,1])

7 © 2010 IBM Corporation 7 List Fragmentation CREATE TABLE customer (id SERIAL, fname CHAR(32), lname CHAR(32), state CHAR(2), phone CHAR(12)) FRAGMENT BY LIST (state) PARTITION p0 VALUES ("KS", "IL") IN dbs0, PARTITION p1 VALUES ("CA", "OR") IN dbs1, PARTITION p2 VALUES ("NY", "MN") IN dbs2, PARTITION p3 VALUES (NULL) IN dbs3, PARTITION p4 REMAINDER IN dbs3;  The fragments do not overlap - no duplicates in the list values: –For example, the following is not allowed PARTITION p0 VALUES ("KS", "IL") IN dbs0, PARTITION p1 VALUES ("CA", "KS") IN dbs1, –The following is also not allowed PARTITION p0 VALUES ("KS", "IL“, "KS") IN dbs0,  The list values must be constant literals: –For example, the following is not allowed PARTITION p0 VALUES (name, "KS", "IL“) IN dbs0,

8 © 2010 IBM Corporation 8 List Fragmentation Strategy - Summary  Helps in the logical segregation of the data.  Useful when a table has finite set of values for the fragment key and queries on table have equality predicate on the fragment key.  Both the table and the index can be fragmented using this strategy.  The fragment key can be an column expression and can contain multiple columns.  Fragments cannot overlap.  Remainder, Null fragments are allowed.

9 © 2010 IBM Corporation 9 Interval Fragmentation Strategy  Fragments data based on an interval value: –For example, a fragment for every month or every million customer records.  Tables have an initial set of fragments defined by a range expression.  When a row is inserted that does not fit in the initial range of fragments, IDS will automatically create a fragment to hold the row (no DBA intervention).

10 © 2010 IBM Corporation 10 Interval Fragmentation - Example CREATE TABLE employee (id INTEGER, name CHAR(32), basepay DECIMAL (10,2), varpay DECIMAL (10,2), dept CHAR(2), hiredate DATE) FRAGMENT BY RANGE (id) INTERVAL (100) STORE IN (dbs1, dbs2, dbs3, dbs4) PARTITION p0 VALUES IS NULL IN dbs0, PARTITION p1 VALUES < 200 IN dbs1, PARTITION p2 VALUES < 400 IN dbs2; –The fragment or partitioning key for interval fragmentation can have only a single column. For example, the following is not allowed: FRAGMENT BY RANGE (basepay + varpay) –The fragment key can be a column expression: FRAGMENT BY RANGE ((ROUND(basepay)) –The fragment key must be numeric, DATE or DATETIME data type: Fragment key “id” in example is a INTEGER data type (numeric)

11 © 2010 IBM Corporation 11 SQL Functions to Specify Interval Values  NUMTOYMINTERVAL(, {"YEAR"|"MONTH"]})  TO_YMINTERVAL(, {"YEAR"|"MONTH"} ) – NUMTOYMINTERVAL(1, "YEAR") = INTERVAL (1-0) YEAR TO MONTH – NUMTOYMINTERVAL(1.5, "YEAR") = INTERVAL (1-6) YEAR TO MONTH  _____________________________________________________________________________________________________  NUMTODSINTERVAL(, {"DAY" | "HOUR" | "MINUTE" | "SECOND"})  TO_DSINTERVAL(, {"DAY" | "HOUR" | "MINUTE" | "SECOND"})  NUMTODSINTERVAL(1.5, "DAY") = INTERVAL (1 12:00:00) DAY TO SECOND  NUMTODSINTERVAL(1.5, "HOUR") = INTERVAL (0 01:30:00) DAY TO SECOND  NUMTODSINTERVAL(1.5, "MINUTE") = INTERVAL (0 00:01:30) DAY TO SECOND

12 © 2010 IBM Corporation 12 SQL Functions to Specify Interval Values (cont'd)  TO_YMINTERVAL("YY-mm");  TO_YMINTERVAL("01-00") = INTERVAL (1-0) YEAR TO MONTH  TO_YMINTERVAL("00-01’) = INTERVAL (0-1) YEAR TO MONTH  TO_YMINTERVAL("01-06") = INTERVAL (1-6) YEAR TO MONTH  _____________________________________________________________________________________________________  TO_DSINTERVAL("DD HH:MM:SS")  TO_DSINTERVAL("1 12:00:00") = INTERVAL (1 12:00:00) DAY TO SECOND  TO_DSINTERVAL("0 01:30:00") = INTERVAL (0 01:30:00) DAY TO SECOND  TO_DSINTERVAL("0 00:01:30") = INTERVAL (0 00:01:30) DAY TO SECOND

13 © 2010 IBM Corporation 13 SQL Functions CREATE TABLE orders (order_id INT, cust_id INT, order_date DATE, order_desc CHAR (1024) FRAGMENT BY RANGE (order_date) INTERVAL (NUMTOYMINTERVAL (1.5,’YEAR’)) STORE IN (dbs1, dbs2, dbs3) PARTITION p0 VALUES < DATE (‘01/01/2004’) IN dbs0, PARTITION p1 VALUES < DATE (‘01/01/2006’) IN dbs1, PARTITION p2 VALUES < DATE (‘01/01/2008’) IN dbs2, PARTITION p3 VALUES < DATE (‘01/01/2010’) IN dbs3;

14 © 2010 IBM Corporation 14 Interval Fragmentation Strategy

15 © 2010 IBM Corporation 15 Interval Fragmentation Strategy - Summary  Useful when DBA does not want to pre-allocate fragments for data that is not yet there.  Both table and index can be fragmented using this strategy.  Only single column expressions for fragment keys.  Only numeric, DATE or DATETIME types for fragment key column.  The interval value supports only a non-zero positive numeric or INTERVAL constant literal expression.

16 © 2010 IBM Corporation 16 Questions?

17 © 2010 IBM Corporation September 9, 2010 OAT - List / Interval Fragmentation Strategies

18 © 2010 IBM Corporation 18 Fragment by List and Interval (1)  You can specify a fragmentation strategy by using the OAT Schema Manager plug-in.  On the OAT menu, expand SQL ToolBox > Schema Manager.  These fragmentation strategies provide additional ways to control how data is stored on disk.

19 © 2010 IBM Corporation 19 Fragment by List and Interval (2)  Select a database. Then on the Actions menu, click Create Table.  The first two pages of the Create Table Wizard guide you through defining the columns and the primary, foreign, and unique keys.

20 © 2010 IBM Corporation 20 Fragment by List and Interval (3)  On page 3 of the wizard, you can define the fragmentation strategy for the table.

21 © 2010 IBM Corporation 21 Fragment by List Specify the values Specify the fragment key column Select the dbspaces Specify the null and remainder partitions OAT generates the SQL for the table  Fragment the data based on a list of discrete values; for example, states in a country.

22 © 2010 IBM Corporation 22 Fragment by Interval  In OAT, fragment by interval is separated into two options: Date-range fragmentation: for DATE and DATETIME columns. Range fragmentation: for numeric columns.  For ease of use in either strategy: You specify only one predefined partition and the interval. When a row is inserted that does not match the range of any existing fragment, the database server creates a fragment based on the specified interval.

23 © 2010 IBM Corporation 23 Fragment by Date Range Specify the start date for automatic fragmentation Specify the interval in days, months, or years Specify the fragment key column Specify the dbspaces Specify null partition OAT generates the SQL  Fragment the data based on a date interval.

24 © 2010 IBM Corporation 24 Questions?

25 © 2010 IBM Corporation September 9, 2010 Fragmentation – ALTER FRAGMENT Support List and Interval Strategies

26 © 2010 IBM Corporation 26 ALTER FRAGMENT  Statement to change the distribution strategy or the storage location of an existing table or index.  Supports the following tasks: –INIT –ADD –ATTACH –DROP –DETACH –MODIFY

27 © 2010 IBM Corporation 27 ALTER FRAGMENT – INIT (1)  Defines and initializes a fragmentation strategy on a table: –Convert an interval or list fragmented table/index to any other type of fragmentation. –Convert any type of fragmented table/index to an interval or list fragmented table/index. –Convert a non-fragmented table/index to interval or list fragmented table/index. –Convert interval or list fragmented table/index to a non- fragmented table/index.

28 © 2010 IBM Corporation 28 ALTER FRAGMENT – INIT (2)  Defines and initializes a fragmentation strategy on a table (cont’d): –Move the table to another set of dbspaces. –Change the order of evaluation of fragment expressions (only supported with list fragmentation strategy). –Change the partitioning key or fragment key. –Change the interval value (for interval fragmentation strategy only). –Table and indexes are rebuilt from scratch.

29 © 2010 IBM Corporation 29 ALTER FRAGMENT – INIT example CREATE TABLE customer (id SERIAL, fname CHAR(32), lname CHAR(32), state CHAR(2), phone CHAR(12)); ALTER FRAGMENT ON TABLE customer INIT FRAGMENT BY RANGE (id) INTERVAL (1000) STORE IN (dbs1, dbs2, dbs3, dbs4) PARTITION p0 VALUES < 2000 IN dbs0; ALTER FRAGMENT ON TABLE customer INIT FRAGMENT BY LIST (state) PARTITION p0 VALUES ("KS", "IL") IN dbs0, PARTITION p1 VALUES ("CA", "OR") IN dbs0, PARTITION p2 REMAINDER IN dbs1; ALTER FRAGMENT ON TABLE customer INIT FRAGMENT BY ROUND ROBIN IN dbs0, dbs1, dbs2;

30 © 2010 IBM Corporation 30 ALTER FRAGMENT - ADD  Add a fragment to interval or list fragmented table/index: –Resulting table should not have any overlaps. –For interval fragmentation, fragments can be added only below the transition value. Above the transition value, fragments are created automatically when rows are inserted with values > transition value. –For list fragmentation, one can use BEFORE and AFTER clause to specify the placement position for new fragment: If the BEFORE/AFTER clause is not specified, the new fragment is added at the end or just before remainder fragment, if one exists. –Addition of fragment can cause data to move from existing fragments to the newly added fragment. Only affected fragments are scanned and data moved.

31 © 2010 IBM Corporation 31 ALTER FRAGMENT - ADD  Add dbspace to list of dbspaces for interval fragments: –Add dbspace to STORE IN list.

32 © 2010 IBM Corporation 32 ALTER FRAGMENT – ADD example CREATE TABLE customer (id SERIAL, fname CHAR(32), lname CHAR(32), state CHAR(2),...) FRAGMENT BY LIST (state) PARTITION p0 VALUES ("KS", "IL") IN dbs0, PARTITION p1 VALUES ("CA", "OR") IN dbs1; ALTER FRAGMENT ON TABLE customer ADD PARTITION p2 VALUES ("NY", "MN") IN dbs2 BEFORE p1; ALTER FRAGMENT ON TABLE customer ADD PARTITION p3 REMAINDER IN dbs2; CREATE TABLE employee (id INTEGER, name CHAR(32),...) FRAGMENT BY RANGE (id) INTERVAL (100) STORE IN (dbs1, dbs2) PARTITION p1 VALUES < 200 IN dbs1, PARTITION p2 VALUES < 400 IN dbs2;  transition fragment ALTER FRAGMENT ON TABLE employee ADD PARTITION p3 VALUES IS NULL IN dbs1; ALTER FRAGMENT ON TABLE employee ADD PARTITION p4 VALUES <300 in dbs3; ALTER FRAGMENT ON TABLE employee ADD INTERVAL STORE IN (dbs3, dbs4);

33 © 2010 IBM Corporation 33 ALTER FRAGMENT – ATTACH (1)  Provides a way to load large amounts of data incrementally into an existing table.  Use to combine tables that have identical structures into a single table: –Resulting table should not have any overlaps. –For interval fragmentation, fragments can be attached below and above the transition value: You can attach fragments to the initial range portion or the interval portion. –The consumed table has to be non-fragmented. The surviving table has to be fragmented. –Similar to ADD, one can use BEFORE and AFTER clause to specify the placement position for the fragment being attached (list fragmentation only).

34 © 2010 IBM Corporation 34 ALTER FRAGMENT – ATTACH (2) –Attaching a fragment can cause data to move from a consumed table to other fragments of the surviving table. –If a REMAINDER fragment is present, data can move from that fragment to the consumed table fragment. Only affected fragments are scanned and data moved: If check constraint exists on the consumed table that exactly matches the fragment expression being attached and there are no remainder fragments, there is no data movement. –An attach operation can reuse the existing indexes and avoid rebuilds, if the indexes are fragmented the same as the table or with the same set of fragment expressions as the table.

35 © 2010 IBM Corporation 35 ALTER FRAGMENT – ATTACH example CREATE TABLE customer (id INTEGER, fname CHAR(32), lname CHAR(32), state CHAR(2),...) FRAGMENT BY LIST (state) PARTITION p0 VALUES ("KS", "IL") IN dbs0, PARTITION p1 VALUES ("CA", "OR") IN dbs1; CREATE TABLE customer2 (id INTEGER, fname CHAR(32), lname CHAR(32), state CHAR(2),...)[ ALTER FRAGMENT ON TABLE customer ATTACH customer2 AS PARTITION p2 VALUES ("NY", "MN") AFTER p1; ALTER FRAGMENT ON TABLE customer ATTACH customer2 AS PARTITION pn VALUES (NULL) BEFORE p0; ALTER FRAGMENT ON TABLE customer ATTACH customer2 AS PARTITION p3 VALUES ("TX"); ALTER FRAGMENT ON TABLE customer ATTACH customer2 AS PARTITION pr REMAINDER;

36 © 2010 IBM Corporation 36 ALTER FRAGMENT - DROP  Drop a fragment from an interval or list fragmented table/index: –Cannot drop a fragment containing data that cannot be moved to another fragment For interval fragmentation, you cannot drop an interval fragment unless its empty. –You can drop a fragment even if the table has only two fragments provided it meets the previous criteria The resultant table is a fragmented table. Both interval and list fragmentation supports single fragment tables/indexes. For interval fragmentation, the resultant table must have at least one range fragment. –Dropping a fragment can cause data to move from fragment being dropped to other fragments in a table. Only affected fragments are scanned and data moved.

37 © 2010 IBM Corporation 37 ALTER FRAGMENT - DROP  Drop dbspace from list of dbspaces for interval fragments: –Drop dbspace from STORE IN list.

38 © 2010 IBM Corporation 38 ALTER FRAGMENT – DROP example CREATE TABLE customer (id SERIAL, fname CHAR(32), lname CHAR(32), state CHAR(2),...) FRAGMENT BY LIST (state) PARTITION pn VALUES (NULL) in dbs3, PARTITION p0 VALUES ("KS", "IL") IN dbs0, PARTITION p1 VALUES ("CA", "OR") IN dbs1, PARTITION p2 REMAINDER IN dbs3; ALTER FRAGMENT ON TABLE customer DROP PARTITION p1; ALTER FRAGMENT ON TABLE customer DROP PARTITION pn;

39 © 2010 IBM Corporation 39 ALTER FRAGMENT – DROP example CREATE TABLE employee (id INTEGER, name CHAR(32),...) FRAGMENT BY RANGE (id) INTERVAL (100) STORE IN (dbs1, dbs2, dbs3, dbs4) PARTITION p1 VALUES < 200 IN dbs1, PARTITION p2 VALUES < 400 IN dbs2;  transition fragment INSERT INTO employee VALUES(401, "Susan",...); INSERT INTO employee VALUES(501, "Robert",...); INSERT INTO employee VALUES(801, "David",...); Fragments in employee table p1 VALUES < 200 p2 VALUES < 400  transition fragment sys_p2 VALUES >= 400 AND VALUES < 500 sys_p3 VALUES >= 500 AND VALUES < 600 sys_p6 VALUES >= 800 AND VALUES < 900 DELETE FROM employee where id = 401; ALTER FRAGMENT ON TABLE employee DROP PARTITION p2; ALTER FRAGMENT ON TABLE employee DROP PARTITION sys_p3; ALTER FRAGMENT ON TABLE employee DROP INTERVAL STORE IN (dbs1, dbs3);

40 © 2010 IBM Corporation 40 ALTER FRAGMENT - DETACH  Provides a way to delete a segment of table data rapidly.  Use to detach a table fragment from a distribution scheme and place the contents into a new non- fragmented table: –Detaching a fragment from a two fragment interval or list table/index does not make the surviving table non-fragmented Both interval and list fragmentation supports single fragment tables/indexes. For interval fragmentation, the resultant table must have at least one range fragment. –Detaching a fragment does not cause data to move but indexes will be rebuilt if they are detached (not fragmented same as table).

41 © 2010 IBM Corporation 41 ALTER FRAGMENT – DETACH example CREATE TABLE customer (id SERIAL, fname CHAR(32), lname CHAR(32), state CHAR(2),...) FRAGMENT BY LIST (state) PARTITION pn VALUES (NULL) in dbs3, PARTITION p0 VALUES ("KS", "IL") IN dbs0, PARTITION p1 VALUES ("CA", "OR") IN dbs1, PARTITION p2 REMAINDER IN dbs3; ALTER FRAGMENT ON TABLE customer DETACH PARTITION p1 customer2; ALTER FRAGMENT ON TABLE customer DETACH PARTITION pn customer3;

42 © 2010 IBM Corporation 42 ALTER FRAGMENT – DETACH example CREATE TABLE employee (id INTEGER, name CHAR(32),...) FRAGMENT BY RANGE (id) INTERVAL (100) STORE IN (dbs1, dbs2, dbs3, dbs4) PARTITION p1 VALUES < 200 IN dbs1, PARTITION p2 VALUES < 400 IN dbs2;  transition fragment INSERT INTO employee VALUES(401, "Susan",...); INSERT INTO employee VALUES(501, "Robert",...); INSERT INTO employee VALUES(801, "David",...); Fragments in employee table p1 VALUES < 200 p2 VALUES < 400  transition fragment sys_p2 VALUES >= 400 AND VALUES < 500 sys_p3 VALUES >= 500 AND VALUES < 600 sys_p6 VALUES >= 800 AND VALUES < 900 ALTER FRAGMENT ON TABLE employee DETACH PARTITION p1 employee2; ALTER FRAGMENT ON TABLE employee DETACH PARTITION sys_p3 employee3;

43 © 2010 IBM Corporation 43 ALTER FRAGMENT – MODIFY (1)  You can enable/disable automatic creation of interval fragments:  ALTER FRAGMENT ON TABLE tab MODIFY INTERVAL ENABLED;  ALTER FRAGMENT ON TABLE tab MODIFY INTERVAL DISABLED;  Modify the dbspace list for interval fragments –Replace an old STORE IN dbspace list with a new one: ALTER FRAGMENT ON TABLE tab MODIFY INTERVAL DISABLED STORE IN (dbs1, dbs2); –Existing fragments in the old dbspace will not be moved.

44 © 2010 IBM Corporation 44 ALTER FRAGMENT – MODIFY (2)  Modify a fragment of an interval or list fragmented table or index: –Rename a fragment or partition. –Relocate a fragment from one dbspace to a different dbspace. –Modify fragment expression Resultant table should not have any overlaps. Data movement possible. For interval fragmentation –First and intermediate range fragments expressions can be modified but new expression should not cross adjacent fragment boundaries. –Last range fragment or transition fragment can be modified to increase the transition value only. –Interval fragment expression cannot be modified.

45 © 2010 IBM Corporation 45 ALTER FRAGMENT – MODIFY Example CREATE TABLE customer (id SERIAL, fname CHAR(32), lname CHAR(32), state CHAR(2),...) FRAGMENT BY LIST (state) PARTITION pn VALUES (NULL) in dbs3, PARTITION p0 VALUES ("KS", "IL") IN dbs0, PARTITION p1 VALUES ("CA", "OR") IN dbs1, PARTITION p2 REMAINDER IN dbs3; ALTER FRAGMENT ON TABLE customer MODIFY PARTITION p1 TO PARTITION newp1, PARTITION p2 TO PARTITION newp2; ALTER FRAGMENT ON TABLE customer MODIFY PARTITION p1 TO PARTITION newp1 IN dbs2, PARTITION p2 TO PARTITION p2 IN dbs6; ALTER FRAGMENT ON TABLE customer MODIFY PARTITION p1 TO PARTITION p1 VALUES (“CA", “OR", “WA") IN dbs1; ALTER FRAGMENT ON TABLE customer MODIFY PARTITION pn TO PARTITION pn VALUES (“TX“) IN dbs2;

46 © 2010 IBM Corporation 46 Questions?

47 © 2010 IBM Corporation September 9, 2010 Fragmentation – Interval Fragmentation ALTER FRAGMENT ONLINE Support

48 © 2010 IBM Corporation 48 ALTER FRAGMENT ONLINE  The following operations can be performed ONLINE for interval fragmentation: –ATTACH of interval fragment. –DETACH of interval fragment. –MODIFY interval transition value.  Using the above options, fragments of a table can be rolled-on and rolled-off ONLINE (without X-lock).  Operation is performed in the background.  Table cannot be exclusively locked at the time of the operation commencement.  ALTER FRAGMENT ONLINE FOR TABLE allows range interval fragmentation only.

49 © 2010 IBM Corporation 49 Example – Table Schema  Table schema that will be used in the rest of the presentation: CREATE TABLE orders (order_id INT, cust_id INT, order_date DATE, …) FRAGMENT BY RANGE (order_date) INTERVAL (1 UNITS YEAR) STORE IN (dbs1, dbs2, dbs3, dbs4) PARTITION p0 VALUES < DATE (‘01/01/2005’) IN dbs0; INSERT INTO orders VALUES (1001, 106, ’04/15/2005’, …); INSERT INTO orders VALUES (1102, 135, ’06/19/2006’, …); INSERT INTO orders VALUES (1148, 122, ’10/23/2007’, …); INSERT INTO orders VALUES (1190, 108, ’02/22/2008’, …); INSERT INTO orders VALUES (1202, 142, ’12/15/2008’, …); INSERT INTO orders VALUES (1510, 127, ’03/12/2009’, …); INSERT INTO orders VALUES (1611, 108, ’08/10/2009’, …);

50 © 2010 IBM Corporation 50 Table Fragments  Fragments of the ‘orders’ table (the sys_p* fragments below automatically created after the inserts of the previous slide) p0 < 01/01/2005 - range fragment (also the transition fragment) sys_p1 >= 01/01/2005 AND < 01/01/2006 - interval fragment – yr 2005 sys_p2 >= 01/01/2006 AND < 01/01/2007 - interval fragment – yr 2006 sys_p3 >= 01/01/2007 AND < 01/01/2008 - interval fragment – yr 2007 sys_p4 >= 01/01/2008 AND < 01/01/2009 - interval fragment – yr 2008 sys_p5 >= 01/01/2009 AND < 01/01/2010 - interval fragment – yr 2009

51 © 2010 IBM Corporation 51 ALTER FRAGMENT ONLINE syntax >>-ALTER FRAGMENT ---+--------+-----ON-----------------------------> '-ONLINE-' (1) >--+-TABLE--surviving_table--+-| ATTACH Clause |-------------+-+->< | | (2) | | | +-| DETACH Clause |-------------+ | | | (3) | | | +-| INIT Clause |---------------+ | | | (4) | | | +-| ADD Clause |----------------+ | | | (5) (6) | | | '-----+-| DROP Clause |-------+-' | | | (7) | | | '-| MODIFY Clause |-----' | | (5) (3) | '-------INDEX--surviving_index--+-| INIT Clause |-------+---' | (4) | +-| ADD Clause |--------+ | (6) | +-| DROP Clause |-------+ | (7) | '-| MODIFY Clause |-----'

52 © 2010 IBM Corporation 52 ALTER FRAGMENT ONLINE – ATTACH (Roll-on) Rules (1)  Surviving table must be range interval fragmented.  Consumed table must be non-fragmented. – There is an exclusive lock on this table during the ONLINE ATTACH operation.  Can attach interval fragments only.  If surviving table has indexes, they must be attached indexes: – i.e. fragmented same as table.  Only 1 table to be consumed may be specified within the syntax.

53 © 2010 IBM Corporation 53 ALTER FRAGMENT ONLINE – ATTACH (Roll-on) Rules (2)  For each index on the surviving table, there must be a matching index on the consumed table: –Example: the index is on same set of columns and if surviving table’s index is unique, then corresponding index on consumed table must be unique.  The indexes on consumed table must be detached and created in same dbspace as the table.  No data movement is allowed: –Data in the consumed table must match the expression being attached. –Enforced by a check constraint on the consumed table.

54 © 2010 IBM Corporation 54 ALTER FRAGMENT ONLINE – ATTACH Fragments before attach p0 < 01/01/2005 - r ange fragment (also the transition fragment) sys_p1 >= 01/01/2005 AND < 01/01/2006 - interval fragment – yr 2005 sys_p2 >= 01/01/2006 AND < 01/01/2007 - interval fragment – yr 2006 sys_p3 >= 01/01/2007 AND < 01/01/2008 - interval fragment – yr 2007 sys_p4 >= 01/01/2008 AND < 01/01/2009 - interval fragment – yr 2008 sys_p5 >= 01/01/2009 AND < 01/01/2010 - interval fragment – yr 2009 CREATE TABLE orders2010 (order_id INT, cust_id INT, order_date DATE, …, CHECK (order_date >= DATE('01/01/2010') AND order_date < DATE('01/01/2011'))); ALTER FRAGMENT ONLINE ON TABLE orders ATTACH orders2010 AS PARTITION p6 VALUES < DATE(‘01/01/2011’); Fragments after attach p0 < 01/01/2005 - range fragment (also the transition fragment) sys_p1 >= 01/01/2005 AND < 01/01/2006 - interval fragment – yr 2005 sys_p2 >= 01/01/2006 AND < 01/01/2007 - interval fragment – yr 2006 sys_p3 >= 01/01/2007 AND < 01/01/2008 - interval fragment – yr 2007 sys_p4 >= 01/01/2008 AND < 01/01/2009 - interval fragment – yr 2008 sys_p5 >= 01/01/2009 AND < 01/01/2010 - interval fragment – yr 2009 p6 >= 01/01/2010 AND < 01/01/2011 - interval fragment – yr 2010

55 © 2010 IBM Corporation 55 ALTER FRAGMENT ONLINE – DETACH (Roll-Off)  Surviving table must be range interval fragmented.  If surviving table has indexes, they must be attached indexes i.e. fragmented same as table.  Can detach IDS auto generated interval fragments above the initial user defined range only: –Range fragments initially defined by the user cannot be detached online.  If there are sessions accessing the fragment being detached, it is recommended that user set lock mode to wait to prevent non-exclusive access errors: –The server will wait for the specified amount of time for concurrent sessions to exit the partition. –New sessions will be disallowed on the fragment being detached.

56 © 2010 IBM Corporation 56 ALTER FRAGMENT ONLINE – DETACH Fragments before detach p0 < 01/01/2005 - range fragment (also the transition fragment) sys_p1 >= 01/01/2005 AND < 01/01/2006 - interval fragment – yr 2005 sys_p2 >= 01/01/2006 AND < 01/01/2007 - interval fragment – yr 2006 sys_p3 >= 01/01/2007 AND < 01/01/2008 - interval fragment – yr 2007 sys_p4 >= 01/01/2008 AND < 01/01/2009 - interval fragment – yr 2008 sys_p5 >= 01/01/2009 AND < 01/01/2010 - interval fragment – yr 2009 p6 >= 01/01/2010 AND < 01/01/2011 - interval fragment – yr 2010 ALTER FRAGMENT ONLINE ON TABLE orders DETACH PARTITION sys_p1 orders2005; Fragments after detach p0 < 01/01/2005 - range fragment (also the transition fragment) sys_p2 >= 01/01/2006 AND < 01/01/2007 - interval fragment – yr 2006 sys_p3 >= 01/01/2007 AND < 01/01/2008 - interval fragment – yr 2007 sys_p4 >= 01/01/2008 AND < 01/01/2009 - interval fragment – yr 2008 sys_p5 >= 01/01/2009 AND < 01/01/2010 - interval fragment – yr 2009 p6 >= 01/01/2010 AND < 01/01/2011 - interval fragment – yr 2010

57 © 2010 IBM Corporation 57 ALTER FRAGMENT ONLINE - MODIFY  Surviving table must be range interval fragmented.  Only the transition value can be modified online: –The starting value for interval fragments.  Background operation if no initial errors.  Intent Exclusive Lock held on the table during the operation.

58 © 2010 IBM Corporation 58 ALTER FRAGMENT ONLINE – MODIFY Fragments before modify p0 < 01/01/2005 - range fragment (also the transition fragment) sys_p2 >= 01/01/2006 AND < 01/01/2007 - interval fragment – yr 2006 sys_p3 >= 01/01/2007 AND < 01/01/2008 - interval fragment – yr 2007 sys_p4 >= 01/01/2008 AND < 01/01/2009 - interval fragment – yr 2008 sys_p5 >= 01/01/2009 AND < 01/01/2010 - interval fragment – yr 2009 p6 >= 01/01/2010 AND < 01/01/2011 - interval fragment – yr 2010 ALTER FRAGMENT ONLINE ON TABLE orders MODIFY INTERVAL TRANSITION TO ‘01/01/2006’; Fragments after modify p0 < 01/01/2006 - range fragment (also the transition fragment) sys_p2 >= 01/01/2006 AND < 01/01/2007 - interval fragment – yr 2006 sys_p3 >= 01/01/2007 AND < 01/01/2008 - interval fragment – yr 2007 sys_p4 >= 01/01/2008 AND < 01/01/2009 - interval fragment – yr 2008 sys_p5 >= 01/01/2009 AND < 01/01/2010 - interval fragment – yr 2009 p6 >= 01/01/2010 AND < 01/01/2011 - interval fragment – yr 2010

59 © 2010 IBM Corporation 59 Questions?

60 © 2010 IBM Corporation September 9, 2010 Scott Pickett – WW IDS Technical Sales For questions about this presentation contact: spickett@us.ibm.comspickett@us.ibm.com

61 © 2010 IBM Corporation 61 Logo

62 © 2010 IBM Corporation 62 Logo

63 © 2010 IBM Corporation 63


Download ppt "© 2010 IBM Corporation September 9, 2010 IDS 11.7 – New Fragmentation Strategies Scott Pickett – WW Informix Technical Sales For questions about this presentation."

Similar presentations


Ads by Google