OracleDatabase10gSQLTuning原厂教材Les13RW

上传人:E**** 文档编号:91246526 上传时间:2019-06-26 格式:PPT 页数:34 大小:231.50KB
返回 下载 相关 举报
OracleDatabase10gSQLTuning原厂教材Les13RW_第1页
第1页 / 共34页
OracleDatabase10gSQLTuning原厂教材Les13RW_第2页
第2页 / 共34页
OracleDatabase10gSQLTuning原厂教材Les13RW_第3页
第3页 / 共34页
OracleDatabase10gSQLTuning原厂教材Les13RW_第4页
第4页 / 共34页
OracleDatabase10gSQLTuning原厂教材Les13RW_第5页
第5页 / 共34页
点击查看更多>>
资源描述

《OracleDatabase10gSQLTuning原厂教材Les13RW》由会员分享,可在线阅读,更多相关《OracleDatabase10gSQLTuning原厂教材Les13RW(34页珍藏版)》请在金锄头文库上搜索。

1、Optimizer Hints,Objectives,After completing this lesson, you should be able to specify hints for: Optimizer mode Query transformation Access path Join orders Join methods,Optimizer Hints: Overview,Optimizer hints: Are used to alter execution plans Influence optimizer decisions Provide a mechanism to

2、 instruct the optimizer to choose a certain query execution plan,Types of Hints,Specifying Hints,hint,comment text,*/,/*+,hint,comment text,-+,Rules for Hints,Place hints immediately after the first SQL keyword of a statement block. Each statement block can have only one hint comment, but it can con

3、tain multiple hints. Hints apply to only the statement block in which they appear. If a statement uses aliases, hints must reference aliases rather than table names.,Hint Recommendations,Use hints carefully because they imply a high maintenance load. Be aware of the performance impact of hard-coded

4、hints when they become less valid.,Optimizer Hint Syntax: Example,UPDATE /*+ INDEX(p PRODUCTS_PROD_CAT_IX)*/ products p SET p.prod_min_price = (SELECT (pr.prod_list_price*.95) FROM products pr WHERE p.prod_id = pr.prod_id) WHERE p.prod_category = Men AND p.prod_status = available, on stock /,Hint Ca

5、tegories,There are hints for: Optimization approaches and goals Access paths Query transformations Join orders Join operation Parallel execution,Optimization Goals and Approaches,Hints for Access Paths,Full Notes Page,Hints for Access Paths,Full Notes Page,INDEX_COMBINE Hint: Example,SELECT -+INDEX_

6、COMBINE(CUSTOMERS) cust_last_name FROM SH.CUSTOMERS WHERE ( CUST_GENDER= F AND CUST_MARITAL_STATUS = single) OR CUST_YEAR_OF_BIRTH BETWEEN 1917 AND 1920;,INDEX_COMBINE Hint: Example,Execution Plan - 0 SELECT STATEMENT Optimizer=CHOOSE (Cost=491 Card=10481 Bytes =167696) 1 0 TABLE ACCESS (BY INDEX RO

7、WID) OF CUSTOMERS (Cost=491 ) 2 1 BITMAP CONVERSION (TO ROWIDS) 3 2 BITMAP OR 4 3 BITMAP AND 5 4 BITMAP INDEX (SINGLE VALUE) OF CUST_MARITAL_BIX 6 4 BITMAP INDEX (SINGLE VALUE) OF CUST_GENDER_BIX 7 3 BITMAP MERGE 7 BITMAP INDEX (RANGE SCAN) OF CUST_YOB_BIX,Hints for Query Transformation,Hints for Qu

8、ery Transformation,Full Notes Page,Hints for Join Orders,Full Notes Page,Hints for Join Operations,Full Notes Page,Other Hints,Full Notes Page,Hints for Suppressing Index Usage,Hints and Views,Do not use hints in views. Use view-optimization techniques: Statement transformation Results accessed like

9、 a table Hints can be used on mergeable views and nonmergeable views.,Full Notes Page,Hints for View Processing,Global and Local Hints,Extended hint syntax enables the specifying of (global) hints through views. References a table name in the hint with a dot notation,CREATE view city_view AS SELECT

10、* FROM customers c WHERE cust_city like S%; SELECT /*+ index(v.c cust_credit_limit_idx) */ v.cust_last_name, v.cust_credit_limit FROM city_view v WHERE cust_credit_limit 5000;,Specifying a Query Block in a Hint,Explain plan for SELECT employee_id, last_name FROM hr.employees e WHERE last_name = Smit

11、h; SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY(NULL, NULL, ALL);,SELECT /*+ QB_NAME(qb) FULL(qb e) */ employee_id, last_name FROM hr.employees e WHERE employee_id = 100;,1,2,Full Notes Page,Specifying a Full Set of Hints,SELECT /*+ LEADING(e2 e1) USE_NL(e1) INDEX(e1 emp_emp_id_pk) USE_MER

12、GE(j) FULL(j) */ e1.first_name, e1.last_name, j.job_id, sum(e2.salary) total_sal FROM hr.employees e1, hr.employees e2, hr.job_history j WHERE e1.employee_id = e2.manager_id AND e1.employee_id = j.employee_id AND e1.hire_date = j.start_date GROUP BY e1.first_name, e1.last_name, j.job_id ORDER BY total_sal;,Summary,In this lesson, you should have learned how to: Set the optimizer mode Use optimizer hint syntax Determine access-path hints Analyze hints and their impact on views,

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 高等教育 > 大学课件

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号