db2像oracle一样使用hints(guidelines)
2015-12-03 00:53
399 查看
db2像oracle一样使用hints(guidelines)C:\DB2>more f3.sqlSELECT d.DEPTNAME,e.FIRSTNME,e.LASTNAMEFROM DEPARTMENT D,EMPLOYEE EWHERE d.DEPTNO = e.WORKDEPT AND e.EMPNO LIKE '0001%' /*<OPTGUIDELINES><MSJOIN><TBSCAN TABLE='D'/> <TBSCAN TABLE='E'/></MSJOIN></OPTGUIDELINES>*/;
C:\DB2>C:\DB2>db2expln -d sample -f f3.sql -g -t -z ";"
DB2 Universal Database Version 10.5, 5622-044 (c) Copyright IBM Corp. 1991, 2012Licensed Material - Program Property of IBMIBM DB2 Universal Database SQL and XQUERY Explain Tool
DB2 Universal Database Version 10.5, 5622-044 (c) Copyright IBM Corp. 1991, 2012Licensed Material - Program Property of IBMIBM 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", "LIAO"
Statement:
SELECT d.DEPTNAME, e.FIRSTNME, e.LASTNAME FROM DEPARTMENT D, EMPLOYEE E WHERE d.DEPTNO =e.WORKDEPT AND e.EMPNO LIKE '0001%' /*<OPTGUIDELINES> <MSJOIN> <TBSCAN TABLE='D' /> <TBSCAN TABLE='E' /> </MSJOIN> </OPTGUIDELINES>*/
Section Code Page = 1208
Estimated Cost = 13.634712Estimated Cardinality = 9.816054
Access Table Name = LIAO.EMPLOYEE ID = 2,6| Index Scan: Name = LIAO.PK_EMPLOYEE ID = 1| | Regular Index (Not Clustered)| | Index Columns:| | | 1: EMPNO (Ascending)| #Columns = 4| Skip Inserted Rows| Avoid Locking Committed Data| Currently Committed for Cursor Stability| Evaluate Predicates Before Locking for Key| #Key Columns = 1| | Start Key: Inclusive Value| | | 1: '0001'| | Stop Key: Inclusive Value| | | 1: '0001 '| Data Prefetch: Sequential(0), Readahead| Index Prefetch: None| Lock Intents| | Table: Intent Share| | Row : Next Key Share| Sargable Predicate(s)| | Process Build Table for Hash JoinHash Join| Early Out: Single Match Per Inner Row| Estimated Build Size: 4000| Estimated Probe Size: 4000| Access Table Name = LIAO.DEPARTMENT ID = 2,5| | #Columns = 2| | Skip Inserted Rows| | Avoid Locking Committed Data| | Currently Committed for Cusor 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)| | | Process Probe Table for Hash JoinReturn Data to Application| #Columns = 3
End of section
Optimizer Plan:
Rows Operator (ID) Cost
9.81605 RETURN ( 1) 13.6347 | 9.81605 HSJOIN ( 2) 13.6347 / \ 14 9.81605 TBSCAN FETCH ( 3) ( 4) 6.81583 6.8181 | / \ 14 9.81605 42 Table: IXSCAN Table: LIAO ( 5) LIAO DEPARTMENT 0.00986447 EMPLOYEE | 42 Index: LIAO PK_EMPLOYEE
C:\DB2>db2set DB2_OPTPROFILE=YES
C:\DB2>db2set -all[e] DB2PATH=C:\v105\IBM\SQLLIB[i] DB2_OPTPROFILE=YES[i] DB2INSTOWNER=LIAO-PC[i] DB2PORTRANGE=60000:60005[i] DB2INSTPROF=C:\V105\PROGRAMDATA\\IBM\DB2\DB2COPY1[i] DB2COMM=TCPIP[g] DB2_EXTSECURITY=NO[g] DB2_COMMON_APP_DATA_PATH=C:\v105\ProgramData\[g] DB2SYSTEM=LIAO-PC[g] DB2PATH=C:\v105\IBM\SQLLIB[g] DB2INSTDEF=DB2[g] DB2ADMINSERVER=DB2DAS00
C:\DB2>db2stop2015-12-04 00:43:34 0 0 SQL1025N 未停止数据库,因为数据库仍是活动的。SQL1025N 未停止数据库,因为数据库仍是活动的。
C:\DB2>db2stop force2015-12-04 00:43:40 0 0 SQL1064N DB2STOP 处理成功。SQL1064N DB2STOP 处理成功。
C:\DB2>db2start2015-12-04 00:43:48 0 0 SQL1063N DB2START 处理成功。SQL1063N DB2START 处理成功。
C:\DB2>db2expln -d sample -f f3.sql -g -t -z ";"
DB2 Universal Database Version 10.5, 5622-044 (c) Copyright IBM Corp. 1991, 2012Licensed Material - Program Property of IBMIBM DB2 Universal Database SQL and XQUERY Explain Tool
DB2 Universal Database Version 10.5, 5622-044 (c) Copyright IBM Corp. 1991, 2012Licensed Material - Program Property of IBMIBM 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", "LIAO"
Statement:
SELECT d.DEPTNAME, e.FIRSTNME, e.LASTNAME FROM DEPARTMENT D, EMPLOYEE E WHERE d.DEPTNO =e.WORKDEPT AND e.EMPNO LIKE '0001%' /*<OPTGUIDELINES> <MSJOIN> <TBSCAN TABLE='D' /> <TBSCAN TABLE='E' /> </MSJOIN> </OPTGUIDELINES>*/
Section Code Page = 1208
Estimated Cost = 13.648438Estimated Cardinality = 9.816054
Access Table Name = LIAO.DEPARTMENT ID = 2,5| #Columns = 2| 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)| | Insert Into Sorted Temp Table ID = t1| | | #Columns = 2| | | #Sort Key Columns = 1| | | | Key 1: DEPTNO (Ascending)| | | Sortheap Allocation Parameters:| | | | #Rows = 14.000000| | | | Row Width = 28| | | PipedSorted Temp Table Completion ID = t1Access Temp Table ID = t1| #Columns = 2| Relation Scan| | Prefetch: EligibleMerge Join| Access Table Name = LIAO.EMPLOYEE ID = 2,6| | #Columns = 4| | 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| | | Insert Into Sorted Temp Table ID = t2| | | | #Columns = 3| | | | #Sort Key Columns = 1| | | | | Key 1: WORKDEPT (Ascending)| | | | Sortheap Allocation Parameters:| | | | | #Rows = 10.000000| | | | | Row Width = 32| | | | Piped| Sorted Temp Table Completion ID = t2| Access Temp Table ID = t2| | #Columns = 3| | Relation Scan| | | Prefetch: EligibleReturn Data to Application| #Columns = 3
End of section
Optimizer Plan:
Rows Operator (ID) Cost
9.81605 RETURN ( 1) 13.6484 | 9.81605 MSJOIN ( 2) 13.6484 / \-\ 14 * TBSCAN | ( 3) 9.81605 6.81692 TBSCAN | ( 7) 14 6.83002 SORT | ( 4) 9.81605 6.81674 SORT | ( 8) 14 6.82983 TBSCAN | ( 5) 9.81605 6.81583 TBSCAN | ( 9) 14 6.82912 Table: | LIAO 42 DEPARTMENT Table: LIAO EMPLOYEE
C:\DB2>
REF:1.Oracle hint在DB2中的实现-访问计划定制http://www.itpub.net/thread-1795527-1-1.html
C:\DB2>C:\DB2>db2expln -d sample -f f3.sql -g -t -z ";"
DB2 Universal Database Version 10.5, 5622-044 (c) Copyright IBM Corp. 1991, 2012Licensed Material - Program Property of IBMIBM DB2 Universal Database SQL and XQUERY Explain Tool
DB2 Universal Database Version 10.5, 5622-044 (c) Copyright IBM Corp. 1991, 2012Licensed Material - Program Property of IBMIBM 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", "LIAO"
Statement:
SELECT d.DEPTNAME, e.FIRSTNME, e.LASTNAME FROM DEPARTMENT D, EMPLOYEE E WHERE d.DEPTNO =e.WORKDEPT AND e.EMPNO LIKE '0001%' /*<OPTGUIDELINES> <MSJOIN> <TBSCAN TABLE='D' /> <TBSCAN TABLE='E' /> </MSJOIN> </OPTGUIDELINES>*/
Section Code Page = 1208
Estimated Cost = 13.634712Estimated Cardinality = 9.816054
Access Table Name = LIAO.EMPLOYEE ID = 2,6| Index Scan: Name = LIAO.PK_EMPLOYEE ID = 1| | Regular Index (Not Clustered)| | Index Columns:| | | 1: EMPNO (Ascending)| #Columns = 4| Skip Inserted Rows| Avoid Locking Committed Data| Currently Committed for Cursor Stability| Evaluate Predicates Before Locking for Key| #Key Columns = 1| | Start Key: Inclusive Value| | | 1: '0001'| | Stop Key: Inclusive Value| | | 1: '0001 '| Data Prefetch: Sequential(0), Readahead| Index Prefetch: None| Lock Intents| | Table: Intent Share| | Row : Next Key Share| Sargable Predicate(s)| | Process Build Table for Hash JoinHash Join| Early Out: Single Match Per Inner Row| Estimated Build Size: 4000| Estimated Probe Size: 4000| Access Table Name = LIAO.DEPARTMENT ID = 2,5| | #Columns = 2| | Skip Inserted Rows| | Avoid Locking Committed Data| | Currently Committed for Cusor 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)| | | Process Probe Table for Hash JoinReturn Data to Application| #Columns = 3
End of section
Optimizer Plan:
Rows Operator (ID) Cost
9.81605 RETURN ( 1) 13.6347 | 9.81605 HSJOIN ( 2) 13.6347 / \ 14 9.81605 TBSCAN FETCH ( 3) ( 4) 6.81583 6.8181 | / \ 14 9.81605 42 Table: IXSCAN Table: LIAO ( 5) LIAO DEPARTMENT 0.00986447 EMPLOYEE | 42 Index: LIAO PK_EMPLOYEE
C:\DB2>db2set DB2_OPTPROFILE=YES
C:\DB2>db2set -all[e] DB2PATH=C:\v105\IBM\SQLLIB[i] DB2_OPTPROFILE=YES[i] DB2INSTOWNER=LIAO-PC[i] DB2PORTRANGE=60000:60005[i] DB2INSTPROF=C:\V105\PROGRAMDATA\\IBM\DB2\DB2COPY1[i] DB2COMM=TCPIP[g] DB2_EXTSECURITY=NO[g] DB2_COMMON_APP_DATA_PATH=C:\v105\ProgramData\[g] DB2SYSTEM=LIAO-PC[g] DB2PATH=C:\v105\IBM\SQLLIB[g] DB2INSTDEF=DB2[g] DB2ADMINSERVER=DB2DAS00
C:\DB2>db2stop2015-12-04 00:43:34 0 0 SQL1025N 未停止数据库,因为数据库仍是活动的。SQL1025N 未停止数据库,因为数据库仍是活动的。
C:\DB2>db2stop force2015-12-04 00:43:40 0 0 SQL1064N DB2STOP 处理成功。SQL1064N DB2STOP 处理成功。
C:\DB2>db2start2015-12-04 00:43:48 0 0 SQL1063N DB2START 处理成功。SQL1063N DB2START 处理成功。
C:\DB2>db2expln -d sample -f f3.sql -g -t -z ";"
DB2 Universal Database Version 10.5, 5622-044 (c) Copyright IBM Corp. 1991, 2012Licensed Material - Program Property of IBMIBM DB2 Universal Database SQL and XQUERY Explain Tool
DB2 Universal Database Version 10.5, 5622-044 (c) Copyright IBM Corp. 1991, 2012Licensed Material - Program Property of IBMIBM 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", "LIAO"
Statement:
SELECT d.DEPTNAME, e.FIRSTNME, e.LASTNAME FROM DEPARTMENT D, EMPLOYEE E WHERE d.DEPTNO =e.WORKDEPT AND e.EMPNO LIKE '0001%' /*<OPTGUIDELINES> <MSJOIN> <TBSCAN TABLE='D' /> <TBSCAN TABLE='E' /> </MSJOIN> </OPTGUIDELINES>*/
Section Code Page = 1208
Estimated Cost = 13.648438Estimated Cardinality = 9.816054
Access Table Name = LIAO.DEPARTMENT ID = 2,5| #Columns = 2| 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)| | Insert Into Sorted Temp Table ID = t1| | | #Columns = 2| | | #Sort Key Columns = 1| | | | Key 1: DEPTNO (Ascending)| | | Sortheap Allocation Parameters:| | | | #Rows = 14.000000| | | | Row Width = 28| | | PipedSorted Temp Table Completion ID = t1Access Temp Table ID = t1| #Columns = 2| Relation Scan| | Prefetch: EligibleMerge Join| Access Table Name = LIAO.EMPLOYEE ID = 2,6| | #Columns = 4| | 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| | | Insert Into Sorted Temp Table ID = t2| | | | #Columns = 3| | | | #Sort Key Columns = 1| | | | | Key 1: WORKDEPT (Ascending)| | | | Sortheap Allocation Parameters:| | | | | #Rows = 10.000000| | | | | Row Width = 32| | | | Piped| Sorted Temp Table Completion ID = t2| Access Temp Table ID = t2| | #Columns = 3| | Relation Scan| | | Prefetch: EligibleReturn Data to Application| #Columns = 3
End of section
Optimizer Plan:
Rows Operator (ID) Cost
9.81605 RETURN ( 1) 13.6484 | 9.81605 MSJOIN ( 2) 13.6484 / \-\ 14 * TBSCAN | ( 3) 9.81605 6.81692 TBSCAN | ( 7) 14 6.83002 SORT | ( 4) 9.81605 6.81674 SORT | ( 8) 14 6.82983 TBSCAN | ( 5) 9.81605 6.81583 TBSCAN | ( 9) 14 6.82912 Table: | LIAO 42 DEPARTMENT Table: LIAO EMPLOYEE
C:\DB2>
REF:1.Oracle hint在DB2中的实现-访问计划定制http://www.itpub.net/thread-1795527-1-1.html
相关文章推荐
- oracle 触发器number判断空值,:NEW赋值,for each row,sql变量引号,to_date,to_char
- Oracle的10046事件
- ORACLE创建表空间、创建用户以及赋值权限
- oracle dbconsole 因为IP改动启动不了,重建方式
- oracle中的检查点Ckpt和SCN号
- Oracle 中的rowid
- Oracle ROWID详解
- SCN号与oracle数据库恢复的关系
- Oracle 中的一些重要V$ 动态性能视图,系统视图和表
- oracle常用动态性能视图
- oracle触发器调试
- Oracle exp imp 常见问题解决
- Mybatis+Oracle实现按条件分页查询
- Oracle异常date format picture ends before converting entire input string ora-01830oracle
- poi解析上传的Excel xlsx 保存到Oracle 趁还没忘记,留下
- pl/sql 连接远程oracle数据库
- win7,64位操作系统安装oracle
- 补装Windows下Oracle client的 OracleMTSRecoveryService
- Oracle 存储过程之通用分页查询
- HACMP 6.1 + ORACLE 10G RAC on AIX6.1 安装文档