我的应用程序有以下SQL脚本(代码检查),我的用户在工作日结束时执行该脚本以重新整理事务表:
DATABASE dbfiles;
UNLOAD TO "U:\UNL\ACTIVES.UNL"
SELECT * FROM transaction
WHERE trx_type IN ("E","I","C","P")
ORDER BY trx_cust_fullname,
trx_last_pymt;
UNLOAD TO "U:\UNL\INACTIVES.UNL"
SELECT * FROM transaction
WHERE trx_type IN ("F","R","T","X","V")
ORDER BY trx_cust_fullname,
trx_last_pymt DESC;
DROP TABLE transaction;
CREATE TABLE transaction
(
trx_store CHAR(2),
trx_cust_fullname CHAR(30),
trx_type CHAR(1),
trx_num SERIAL,
[...]
);
LOAD FROM "U:\UNL\ACTIVES.UNL" INSERT INTO transaction;
LOAD FROM "U:\UNL\INACTIVES.UNL" INSERT INTO transaction;
CREATE CLUSTER INDEX custn_idx ON transaction (trx_cust_fullname);
CREATE UNIQUE INDEX trxn_idx ON transaction (trx_num);
[3 more indexes...]
UPDATE STATISTICS FOR transaction;
TRANS103.IDX的大小只有22089字节!
虽然这个IDX文件大小对我来说不太好,但我用“执行”屏幕查询了事务表中的所有行,所有1083行都可以显示,更新了一些,添加了一些,删除了一些,没有问题,退出了,再次返回,没有遇到任何问题!然后我运行了'bcheck-y TRANS103',结果如下:
S:\DBFILES.DBS> bcheck ây TRANS103
BCHECK C-ISAM B-tree Checker version 4.10.DD6
C-ISAM File: s:\dbfiles.dbs\trans103
Checking dictionary and file sizes.
Index file node size = 512
Current C-ISAM index file node size = 512
Checking data file records.
Checking indexes and key descriptions.
Index 1 = unique key
0 index node(s) used -- 1 index b-tree level(s) used
Index 2 = duplicates (2,30,0)
42 index node(s) used -- 3 index b-tree level(s) used
Index 3 = unique key (32,5,0)
29 index node(s) used -- 2 index b-tree level(s) used
Index 4 = duplicates (242,4,2)
37 index node(s) used -- 2 index b-tree level(s) used
Index 5 = duplicates (241,1,0)
36 index node(s) used -- 2 index b-tree level(s) used
Index 6 = duplicates (46,4,2)
38 index node(s) used -- 2 index b-tree level(s) used
Checking data record and index node free lists.
ERROR: 177 missing index node pointer(s)
Fix index node free list ? yes
Recreating index node free list.
Recreating index 6.
Recreating index 5.
Recreating index 4.
Recreating index 3.
Recreating index 2.
Recreating index 1.
184 index node(s) used, 177 free -- 1083 data record(s) used, 0 free
所以在bcheck之后,现在它的.IDX大小增加到了122561字节,这听起来是正确的大小,所以我回到“Perform”,重复以前的测试,没有遇到任何问题。出于好奇,我再次对它运行bcheck,它重复了与我运行的第一次bcheck相同的结果!。。就像第一次检查没能把桌子修好一样!。。有人知道为什么bcheck再次修复了本该“修复”的东西吗?。。这和聚类索引有关吗?