WEB开发网
开发学院数据库DB2 DB2 中 MQT 的匹配原理及使用技巧 阅读

DB2 中 MQT 的匹配原理及使用技巧

 2010-03-31 00:00:00 来源:WEB开发网   
核心提示: 查看原图(大图)清单 4. 查询中连接的表数目多于 MQT 匹配--MQTdefinition:joinforSALESandPRODUCTCREATETABLEMQTSCH.SALES_PRODAS(SELECTP.PROD_ID,PROD_DESC,AMOUNT,CUST_IDFROMMQT

查看原图(大图)

清单 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". 

上一页  1 2 3 4 5 6 7 8 9 10  下一页

Tags:DB MQT 匹配

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接