(5)db2expln执行计划输出工具
这个工具将指定语句的执行计划输出到终端屏幕或一个文件。下面举例说明db2expln命令格式和输出如下:-d指定数据库名,-q是一个SQL语句,也可以用-f指定某个保存了SQL的文件。-u可以指定用户名和口令。-t表示输出到终端,-o可以输出到文件。
[db2inst1@aix:/home/db2inst1]#>db2expln -d tpch -q "select count(*) cnt from tpch.part where p_size=30" -g -t
IBM DB2 Universal Database SQL and XQUERY 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", "SYSIBMADM",
"DB2INST1"
Statement:
select count(*)cnt
from tpch.part
where p_size=30
Section Code Page = 1208
Estimated Cost = 11047.642578 --估计的成本
Estimated Cardinality = 1.000000 --估计的基数
Access Table Name = TPCH.PART ID = 4,9
| #Columns = 0
| Skip Inserted Rows
| Avoid Locking Committed Data
| Currently Committed for Cursor Stability
| May participate in Scan Sharing structures
| Scan may start anywhere and wrap, for completion
| Fast scan, for purposes of scan sharing management
| Scan can be throttled in scan sharing management
| Relation Scan
| | Prefetch: Eligible
| Lock Intents
| | Table: Intent Share
| | Row : Next Key Share
| Sargable Predicate(s)
| | #Predicates = 1
| | Predicate Aggregation
| | | Column Function(s)
Aggregation Completion
| Column Function(s)
Return Data to Application
| #Columns = 1
End of section
--图形化的执行计划
Optimizer Plan:
Rows
Operator
(ID)
Cost
1
n/a
RETURN
( 1)
11047.6
|
1
n/a
GRPBY
( 2)
11047.6
|
37482.7
n/a
TBSCAN
( 3)
11043.7
|
2.00041e+06
n/a
Table:
TPCH
PART
IBM DB2 Universal Database SQL and XQUERY 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", "SYSIBMADM",
"DB2INST1"
Statement:
select count(*)cnt
from tpch.part
where p_size=30
Section Code Page = 1208
Estimated Cost = 11047.642578 --估计的成本
Estimated Cardinality = 1.000000 --估计的基数
Access Table Name = TPCH.PART ID = 4,9
| #Columns = 0
| Skip Inserted Rows
| Avoid Locking Committed Data
| Currently Committed for Cursor Stability
| May participate in Scan Sharing structures
| Scan may start anywhere and wrap, for completion
| Fast scan, for purposes of scan sharing management
| Scan can be throttled in scan sharing management
| Relation Scan
| | Prefetch: Eligible
| Lock Intents
| | Table: Intent Share
| | Row : Next Key Share
| Sargable Predicate(s)
| | #Predicates = 1
| | Predicate Aggregation
| | | Column Function(s)
Aggregation Completion
| Column Function(s)
Return Data to Application
| #Columns = 1
End of section
--图形化的执行计划
Optimizer Plan:
Rows
Operator
(ID)
Cost
1
n/a
RETURN
( 1)
11047.6
|
1
n/a
GRPBY
( 2)
11047.6
|
37482.7
n/a
TBSCAN
( 3)
11043.7
|
2.00041e+06
n/a
Table:
TPCH
PART