手工修改统计数据之一。在 db2look.out 文件中搜索下列语句(请注重,模式名、TABSCHEMA 和 INDSCHEMA 可能与您的具体情况不同):
UPDATE SYSSTAT.INDEXES
SET NLEAF=1,
NLEVELS=1,
FIRSTKEYCARD=35,
FIRST2KEYCARD=35,
FIRST3KEYCARD=-1,
FIRST4KEYCARD=-1,
FULLKEYCARD=35,
CLUSTERFACTOR=-1.000000,
CLUSTERRATIO=100,
SEQUENTIAL_PAGES=0,
DENSITY=0,
AVERAGE_SEQUENCE_GAP=0.000000,
AVERAGE_SEQUENCE_FETCH_GAP=0.000000,
AVERAGE_SEQUENCE_PAGES=0.000000,
AVERAGE_SEQUENCE_FETCH_PAGES=0.000000,
AVERAGE_RANDOM_PAGES=1.000000,
AVERAGE_RANDOM_FETCH_PAGES=0.000000,
NUMRIDS=35,
NUMRIDS_DELETED=0,
NUM_EMPTY_LEAFS=0
WHERE INDNAME = ’NAME_IND’
AND INDSCHEMA = ’SKAPOOR ’
AND TABNAME = ’STAFF’
AND TABSCHEMA = ’SKAPOOR ’;
现在,将 FIRSTKEYCARD、FIRST2KEYCARD、
FULLKEYCARD 和 NUMRIDS 从 35 修改为 37。现在保存
db2look.out 文件并运行这 3 个文件:
db2 -tvf config.out > config_output.out
db2 -tvf storage.out > storage_output.out
db2 terminate
db2stop
db2start
db2 -tvf db2look.out > db2look_output.out
检查前两个文件 config_output.out 和 storage_output.out 的内容,以确保它们运行成功。现在,检查
db2look_output.out 文件的内容。您将看到下列更新语句失败了:UPDATE SYSSTAT.INDEXES SET NLEAF=1, NLEVELS=1,
正如您可以看到的,上面用于索引 NAME_IND 的 UPDATE 语句失败了,因为 FULLKEYCARD 大于表的基数(CARD)。正如通过
FIRSTKEYCARD=37, FIRST2KEYCARD=37
, FIRST3KEYCARD=-1, FIRST4KEYCARD=-1,
FULLKEYCARD=37, CLUSTERFACTOR=-1.000000, C
LUSTERRATIO=100, SEQUENTIAL_PAGES=0,
DENSITY=0, AVERAGE_SEQUENCE_GAP=0.000000, A
VERAGE_SEQUENCE_FETCH_GAP=0.000000,
AVERAGE_SEQUENCE_PAGES=0.000000, AVERAGE_SEQ
UENCE_FETCH_PAGES=0.000000,
AVERAGE_RANDOM_PAGES=1.000000, AVERAGE_RANDOM_FETCH_
PAGES=0.000000, NUMRIDS=37,
NUMRIDS_DELETED=0, NUM_EMPTY_LEAFS=0 WHERE INDNAME =
’NAME_IND’ AND INDSCHEMA = ’SKAPOOR ’
AND TABNAME = ’STAFF’ AND TABSCHEMA = ’SK
APOOR ’
DB21034E The command was processed as
an SQL statement because it was not a
valid Command Line Processor command.
During SQL processing it returned:
SQL1227N The catalog statistic "37"
for column "FULLKEYCARD" is out of range
for its target column, has an invalid
format, or is inconsistent in relation
to some other statistic. Reason Code = "8".
SQLSTATE=23521
db2look.out 文件中的下列更新语句可以看到的,CARD 是 35:UPDATE SYSSTAT.TABLES
SET CARD=35,
NPAGES=1,
FPAGES=1,
OVERFLOW=0,
ACTIVE_BLOCKS=0
WHERE TABNAME = ’STAFF’ AND TABSCHEMA = ’SKAPOOR ’;
现在,再次以解释模式运行相同的查询:db2 "select name from staff where id=10 order by name"
并生成访问计划。您将看到它是不同的:Access Plan:
-----------
Total Cost: 12.972
Query Degree: 1
Rows
RETURN
( 1)
Cost
I/O
|
1
TBSCAN
( 2)
12.972
1
|
1
SORT
( 3)
12.9708
1
|
1
TBSCAN
( 4)
12.9682
1
|
35
TABLE: SKAPOOR
STAFF
该示例显示,假如在表上发生 WRITE 活动时运行 RUNSTATS,统计数据就可能与本示例中的不一致。因此,用于更新统计数据的 UPDATE
语句可能失败并产生 SQL1227N 错误消息。所有的 UPDATE 语句都运行成功十分重要,假如存在不一致性,就应该进行修理并重新运行。本例中,解决方案是将 KEYCARDS 和 NUMRIDS 从 37 重新修改为 35。