2009年04月30日

これって、REORG ?

IDS 11.50.xC4の表圧縮機能 ( Storage Optimization ) を試しています。
この機能そのものについては、何処かで誰かが結果を紹介してくれると思いますが、付随して、興味深い機能が追加されています。
REPACK / SHRINK という機能を使うと、COMPRESSION とは無関係に、表内の削除済み行などの領域をまとめて未使用エクステントとしてインスタンスに返せるようです。
Information Center-英語版のCompressionの説明を読み漁ってみました。)

Returning Free Space to the dbspace
You can return free space to the dbspace (shrink the space) when you compress, repack, or compress and repack tables or fragments; or you can return free space separately without compressing or repacking. Returning free space reduces the total size of the fragment or table.



以下、実験してみました。。( 実験にはWindows XP 上の IDS 11.50.TC4 を使いました。)...


-----------------------
まず、テストの準備
CREATE DATABASE testdb2 WITH LOG;

CREATE TABLE tab2 (
col1 integer,
col2 char(200)
) LOCK MODE ROW;

CREATE PROCEDURE INS()
DEFINE i INTEGER;
FOR i = 1 TO 4000
INSERT INTO tab2 VALUES (i, "value");
END FOR;
END PROCEDURE;

CREATE PROCEDURE DEL1()
DEFINE i INTEGER;
FOR i = 1 TO 4000 STEP 2
DELETE FROM tab2 WHERE col1 = i;
END FOR;
END PROCEDURE;
------
データを準備
EXECUTE PROCEDURE INS();

実行直後のエクステントの状態
testdb2:'user001'.tab2 879 8

testdb2:'informix'.sysprocbody 887 8

testdb2:'informix'.sysprocplan 895 8

testdb2:'user001'.tab2 903 211

FREE 1114 382886


Total Used: 1114
Total Free: 382886

---
REPACK (表領域内の空き領域をまとめる) と SHRINK (空き領域を表領域から切り離す) を試してみました。。

C:\temp>dbaccess sysadmin -

Database selected.

> EXECUTE FUNCTION task( "table repack shrink", "tab2", "testdb2", "user001" );
(expression) Succeeded: table repack shrink testdb2:user001.tab2

1 row(s) retrieved.

>

---
もう一度oncheck -pe してみると....
testdb2:'user001'.tab2 879 8
testdb2:'informix'.sysprocbody 887 8
testdb2:'informix'.sysprocplan 895 8
testdb2:'user001'.tab2 903 99
FREE 1002 382998


Total Used: 1002
Total Free: 382998

エクステント (データベースtestdb2の、表"informix".tab2に注目、 ) が縮みました。それとともに、Total used の値が減り、Total Freeが増えています。

これって、いわゆるREORGとして利用できるのでしょうか。。
このような操作は、普通より論理ログを消費(浪費)していると思いますので、論理ログのサイズには要注意です。また、操作中に対象の表にどんなロックがかかっているのかは、これから調べたいと思います。以下の記述によると、REPACKは、オンライン(エクスクルーシブロックなし)でも実行できるようですね。

Consolidating Free Space in Tables
You can consolidate (repack) free space in tables and fragments when you compress the tables or fragments or separately without compressing.

You can perform a repack operation online or offline, using the repack or repack_offline parameter. The repack_offline operation is the same as the repack operation, except that Dynamic Server performs the operation while holding an exclusive lock on the table or fragment. This operation prevents all other access to data until the operation is completed.




タグ :cheetah2admin

同じカテゴリー(ちょっと細かいテックネタ)の記事
DBACCESS_COLUMNS
DBACCESS_COLUMNS(2020-04-03 00:33)


※このブログではブログの持ち主が承認した後、コメントが反映される設定です。
上の画像に書かれている文字を入力して下さい
 
<ご注意>
書き込まれた内容は公開され、ブログの持ち主だけが削除できます。