手工修改統計數據之一。在 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,
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
正如您可以看到的,上面用於索引 NAME_IND 的 UPDATE 語句失敗了,因為 FULLKEYCARD 大於表的基數(CARD)。正如通過
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。
轉載:http://www.cncms.com.cn/db2/u351951.Html