To take advantage of the performance improvements for the ALTER FRAGMENT DETACH statement, formulate appropriate distribution schemes for your table and index fragments.
To eliminate the index build during execution of the ALTER FRAGMENT DETACH statement, use one of the following fragmentation strategies:
You fragment an index in the same way as the table when you create a fragmented table and subsequently create an index without specifying a fragmentation strategy.
For example, suppose you create a fragmented table and index with the following SQL statements:
CREATE TABLE tb1(a int) FRAGMENT BY EXPRESSION (a >=0 AND a < 5) IN db1, (a >=5 AND a <10) IN db2, (a >=10 AND a <15) IN db3; CREATE INDEX idx1 ON tb1(a);
The database server fragments the index keys into dbspaces db1, db2, and db3 with the same column a value ranges as the table because the CREATE INDEX statement does not specify a fragmentation strategy.
Suppose you then decide to detach the data in the third fragment with the following SQL statement:
ALTER FRAGMENT ON TABLE tb1 DETACH db3 tb3;
Because the fragmentation strategy of the index is the same as the table, the ALTER FRAGMENT DETACH statement does not rebuild the index after the detach operation. The database server drops the fragment of the index in dbspace db3, updates the system catalog tables, and eliminates the index build.
You fragment an index with the same distribution scheme as the table when you create the index that uses the same fragment expressions as the table.
A common fragmentation strategy is to fragment indexes in the same way as the tables but to specify different dbspaces for the index fragments. This fragmentation strategy of putting the index fragments into different dbspaces from the table can improve the performance of operations such as backup, recovery, and so forth.
For example, suppose you create a fragmented table and index with the following SQL statements:
CREATE TABLE tb1(a int, b int) FRAGMENT BY EXPRESSION (a >=0 AND a < 5) IN db1, (a >=5 AND a <10) IN db2, (a >=10 AND a <15) IN db3; CREATE INDEX idx1 on tb1(a) FRAGMENT BY EXPRESSION (a >=0 AND a< 5) IN db4, (a >=5 AND a< 10) IN db5, (a >=10 AND a<15) IN db6;
Suppose you then decide to detach the data in the third fragment with the following SQL statement:
ALTER FRAGMENT ON TABLE tb1 DETACH db3 tb3;
Because the distribution scheme of the index is the same as the table, the ALTER FRAGMENT DETACH statement does not rebuild the index after the detach operation. The database server drops the fragment of the index in dbspace db3, updates the system catalog tables, and eliminates the index build.
Enterprise Edition Home | Express Edition Home | [ Top of Page | Previous Page | Next Page | Contents | Index ]