DB2 中 MQT 的匹配原理及使用技巧
2010-03-31 00:00:00 来源:WEB开发网查看原图(大图)
清单 4. 查询中连接的表数目多于 MQT 匹配
--MQT definition: join for SALES and PRODUCT
CREATE TABLE MQTSCH.SALES_PROD AS
(SELECT P.PROD_ID, PROD_DESC, AMOUNT, CUST_ID
FROM MQTSCH.PRODUCT P, MQTSCH.SALES S
WHERE P.PROD_ID = S.PROD_ID)
DATA INITIALLY DEFERRED REFRESH DEFERRED;
refresh table MQTSCH.SALES_PROD;
--artifical statistics
runstats on table MQTSCH.SALES_PROD;
update syscat.tables set card=10 where tabname='SALES_PROD';
--collect the explain information
DELETE FROM EXPLAIN_INSTANCE;
explain plan for SELECT P.PROD_ID, PROD_DESC, AMOUNT, C.CUST_ID, CUST_NAME
FROM MQTSCH.PRODUCT P, MQTSCH.SALES S, MQTSCH.CUSTOMER C
WHERE P.PROD_ID = S.PROD_ID
AND S.CUST_ID = C.CUST_ID;
!db2exfmt -1 -d mqtdb -o join_rejoin.plan;
下面是 join_rejoin.plan 打印出的执行计划和诊断信息:
Access Plan:
-----------
Total Cost: 18.8629
Query Degree: 1
Rows
RETURN
( 1)
Cost
I/O
|
20
^NLJOIN
( 2)
18.8629
2
/------+-------\
1 20
TBSCAN FETCH
( 3) ( 4)
9.72148 36.0967
1 4
| /---+----\
1 20 20
TABLE: MQTSCH IXSCAN TABLE: MQTSCH
SALES_PROD ( 5) CUSTOMER
Q2 35.3323 Q1
4
|
20
INDEX: SYSIBM
SQL100124231518010
Q1
Extended Diagnostic Information:
--------------------------------
Diagnostic Identifier: 1
Diagnostic Details: EXP0022W Index has no statistics. The index
"SYSIBM "."SQL100124231518010" has not had
runstats run on it. This can lead to poor
cardinality and predicate filtering estimates.
Diagnostic Identifier: 2
Diagnostic Details: EXP0148W The following MQT or statistical view was
considered in query matching: "MQTSCH ".
"SALES_PROD".
Diagnostic Identifier: 3
Diagnostic Details: EXP0149W The following MQT was used (from those
considered) in query matching: "MQTSCH ".
"SALES_PROD".
- ››db2 对float类型取char后显示科学计数法
- ››DB2中出现SQL1032N错误现象时的解决办法
- ››DB2 锁升级示例
- ››db2诊断系列之---定位锁等待问题
- ››db2 命令选项解释
- ››DB2 最佳实践: 使用 DB2 pureXML 管理 XML 数据的...
- ››DB2 9.5 SQL Procedure Developer 认证考试 735 准...
- ››DB2 9.5 SQL Procedure Developer 认证考试 735 准...
- ››DB2 9.5 SQL Procedure Developer 认证考试 735 准...
- ››DB2 基础: 表空间和缓冲池
- ››DB2 XML 编程,第 1 部分: 理解 XML 数据模型
- ››DB2 pureScale 实战
更多精彩
赞助商链接