查看执行计划 db2expln 使用说明

 单个语句:

d:/> db2expln -d wz20901 -u wzgladm wzglpass -t 
-q "update MAT_MATERIAL set GATHERPLAN_ID=null  where GATHERPLAN_ID =2005178  or GATHERPLAN_ID=32 "

DB2 Universal Database Version 8.1, 5622-044 (c) Copyright IBM Corp. 1991, 2002
Licensed Material - Program Property of IBM
IBM DB2 Universal Database SQL Explain Tool

DB2 Universal Database Version 8.1, 5622-044 (c) Copyright IBM Corp. 1991, 2002
Licensed Material - Program Property of IBM
IBM DB2 Universal Database SQL Explain Tool

******************** DYNAMIC ***************************************

==================== STATEMENT ==========================================

        Isolation Level          = Cursor Stability
        Blocking                 = Block Unambiguous Cursors
        Query Optimization Class = 5

        Partition Parallel       = No
        Intra-Partition Parallel = No

        SQL Path                 = "SYSIBM", "SYSFUN", "SYSPROC", "WZGLADM"


SQL Statement:

  update MAT_MATERIAL set GATHERPLAN_ID=null
  where GATHERPLAN_ID =2005178 or GATHERPLAN_ID=32


Section Code Page = 1386

Estimated Cost = 15083.518555
Estimated Cardinality = 940.719971

Access Table Name = WZGLADM.MAT_MATERIAL  ID = 5,27
|  #Columns = 1
|  Relation Scan
|  |  Prefetch: Eligible
|  Lock Intents
|  |  Table: Intent Exclusive
|  |  Row  : Exclusive
Nested Loop Join
|  Data Stream 1:
|  |  Not Piped
|  |  Table Constructor
|  |  |  2-Row(s)
|  |  Insert Into Temp Table  ID = t1
|  |  |  #Columns = 0
|  End of Data Stream 1
|  Access Temp Table  ID = t1
|  |  #Columns = 0
|  |  Relation Scan
|  |  |  Prefetch: Eligible
|  |  Sargable Predicate(s)
|  |  |  #Predicates = 1
Update:  Table Name = WZGLADM.MAT_MATERIAL  ID = 5,27

End of section



d:/>



脚本:

d:/> db2expln -d wz20901 -u wzgladm wzglpass -t -z ; -f tmp.sql

DB2 Universal Database Version 8.1, 5622-044 (c) Copyright IBM Corp. 1991, 2002
Licensed Material - Program Property of IBM
IBM DB2 Universal Database SQL Explain Tool

DB2 Universal Database Version 8.1, 5622-044 (c) Copyright IBM Corp. 1991, 2002
Licensed Material - Program Property of IBM
IBM DB2 Universal Database SQL Explain Tool

******************** DYNAMIC ***************************************

==================== STATEMENT ==========================================

        Isolation Level          = Cursor Stability
        Blocking                 = Block Unambiguous Cursors
        Query Optimization Class = 5

        Partition Parallel       = No
        Intra-Partition Parallel = No

        SQL Path                 = "SYSIBM", "SYSFUN", "SYSPROC", "WZGLADM"


SQL Statement:

  select GATHERPLAN_ID
  from MAT_MATERIAL
  where GATHERPLAN_ID=2005178 or GATHERPLAN_ID=5 or GATHERPLAN_ID=3


Section Code Page = 1386

Estimated Cost = 128.615417
Estimated Cardinality = 1411.079956

Table Constructor
|  3-Row(s)
Nested Loop Join
|  Access Table Name = WZGLADM.MAT_MATERIAL  ID = 5,27
|  |  Index Scan:  Name = WZGLADM.MAT_IDX_GPLAN_ID  ID = 4
|  |  |  Regular Index (Not Clustered)
|  |  |  Index Columns:
|  |  |  |  1: GATHERPLAN_ID (Ascending)
|  |  #Columns = 1
|  |  #Key Columns = 1
|  |  |  Start Key: Inclusive Value
|  |  |  |  |  1: ?
|  |  |  Stop Key: Inclusive Value
|  |  |  |  |  1: ?
|  |  Index-Only Access
|  |  Index Prefetch: None
|  |  Lock Intents
|  |  |  Table: Intent Share
|  |  |  Row  : Next Key Share
|  |  Sargable Index Predicate(s)
|  |  |  Return Data to Application
|  |  |  |  #Columns = 1
Return Data Completion

End of section



对于稍微复杂的sql,建议使用questcentral中的 SQL turning 功能,比较直观。
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值