不要乱加hint
来源:互联网 发布:c 和java的三大框架 编辑:程序博客网 时间:2024/05/16 08:07
SQL> SELECT id FROM (SELECT /*+ INDEX(si SIE_INVOICES_N3) */ si.id FROM binbin1 si,
2 binbin2 bs where si.id = bs.id and si.type ='AR_INVOICE' AND
3 si.import_failed_reason is null AND (si.imp_into_mis_flag is NULL OR si.imp_into_mis_flag = 'N') AND (si.type != 'AP_INVOICE'
4 OR si.batch_number IS NOT NULL) AND bs.current_status = '300_HAS_APPROVED') WHERE rownum < 6 ;
no rows selected
Elapsed: 00:00:01.76
Execution Plan
----------------------------------------------------------Plan hash value: 1985019629-----------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |-----------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 5 | 235 | 276K (1)| 00:55:23 ||* 1 | COUNT STOPKEY | | | | | ||* 2 | TABLE ACCESS BY INDEX ROWID | SIE_INVOICES | 1 | 24 | 3 (0)| 00:00:01 || 3 | NESTED LOOPS | | 5 | 235 | 276K (1)| 00:55:23 || 4 | TABLE ACCESS BY INDEX ROWID| WFR_BILL_STATUS | 99261 | 2229K| 8743 (1)| 00:01:45 ||* 5 | INDEX RANGE SCAN | WFR_BILL_STATUS_N4 | 99261 | | 679 (1)| 00:00:09 ||* 6 | INDEX RANGE SCAN | SIE_INVOICES_N3 | 1 | | 2 (0)| 00:00:01 |-----------------------------------------------------------------------------------------------------Predicate Information (identified by operation id):--------------------------------------------------- 1 - filter(ROWNUM<6) 2 - filter("SI"."type"='AR_INVOICE' AND ("SI"."type"<>'AP_INVOICE' OR "SI"."BATCH_NUMBER" IS NOT NULL) AND ("SI"."IMP_INTO_MIS_FLAG"='N' OR "SI"."IMP_INTO_MIS_FLAG" IS NULL) AND "SI"."IMPORT_FAILED_REASON" IS NULL) 5 - access("BS"."CURRENT_STATUS"='300_HAS_APPROVED') 6 - access("SI"."id"="BS"."id")Statistics---------------------------------------------------------- 1 recursive calls 0 db block gets 234682 consistent gets 0 physical reads 0 redo size 330 bytes sent via SQL*Net to client 481 bytes received via SQL*Net from client 1 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 0 rows processed
从awr里抓出一个sql,发现有hint,去掉hint后飞速。
SQL>
SQL> SELECT id FROM (SELECT si.id FROM binbin1 si,
2 binbin2 bs where si.id = bs.id and si.type ='AR_INVOICE' AND
3 si.import_failed_reason is null AND (si.imp_into_mis_flag is NULL OR si.imp_into_mis_flag = 'N') AND (si.type != 'GL_VOUCHER'
4 OR si.batch_number IS NOT NULL) AND bs.current_status = '300_HAS_APPROVED') WHERE rownum < 6 ;
no rows selected
Elapsed: 00:00:00.06
Execution Plan----------------------------------------------------------Plan hash value: 144640525-----------------------------------------------------------------------------------------------------| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |-----------------------------------------------------------------------------------------------------| 0 | SELECT STATEMENT | | 5 | 235 | 23 (0)| 00:00:01 ||* 1 | COUNT STOPKEY | | | | | ||* 2 | TABLE ACCESS BY INDEX ROWID | WFR_BILL_STATUS | 1 | 23 | 3 (0)| 00:00:01 || 3 | NESTED LOOPS | | 5 | 235 | 23 (0)| 00:00:01 ||* 4 | TABLE ACCESS BY INDEX ROWID| SIE_INVOICES | 26 | 624 | 5 (0)| 00:00:01 ||* 5 | INDEX RANGE SCAN | SIE_INVOICES_N8 | 107 | | 3 (0)| 00:00:01 ||* 6 | INDEX RANGE SCAN | WFR_BILL_STATUS_N2 | 1 | | 2 (0)| 00:00:01 |-----------------------------------------------------------------------------------------------------Predicate Information (identified by operation id):--------------------------------------------------- 1 - filter(ROWNUM<6) 2 - filter("BS"."CURRENT_STATUS"='300_HAS_APPROVED') 4 - filter(("SI"."IMP_INTO_MIS_FLAG"='N' OR "SI"."IMP_INTO_MIS_FLAG" IS NULL) AND ("SI"."type"<>'GL_VOUCHER' OR "SI"."BATCH_NUMBER" IS NOT NULL) AND "SI"."IMPORT_FAILED_REASON" IS NULL) 5 - access("SI"."type"='AR_INVOICE') 6 - access("SI"."id"="BS"."id")Statistics---------------------------------------------------------- 1 recursive calls 0 db block gets 33 consistent gets 8 physical reads 0 redo size 330 bytes sent via SQL*Net to client 481 bytes received via SQL*Net from client 1 SQL*Net roundtrips to/from client 0 sorts (memory) 0 sorts (disk) 0 rows processed
- 不要乱加hint
- 不要乱,一步一步慢慢走
- chmod 777 不要乱设置
- 不要乱碰别人的人生
- Cmd 中 空格不要乱空
- 非必须不要乱使用正则
- 遇到问题时不要乱了方寸
- 办公区不要乱接路由器哦
- Hint
- hint
- Hint
- hint
- hint
- hint
- hint
- HINT
- HINT
- 深入理解Oracle索引(9):不要过分依赖 HINT
- 从抽象谈起(三):AOP编程和ASP.NET MVC
- GSL曲线拟合2
- Java中的反射机制
- Typedef用法总结
- Ubuntu安装Mac皮肤
- 不要乱加hint
- class callback
- Android为自定义控件添加事件
- hdu(2717)Catch That Cow
- 固定网页背景图同时保持图片比例
- ArcGIS自定义坐标系统(以Albers为例)
- mahout的数据文件格式
- 自动化测试代码的实现
- java多线程中synchronized关键字的用法