当前位置:网站首页>Talk about SQL profile again: can I fix the execution plan?

Talk about SQL profile again: can I fix the execution plan?

2022-06-22 22:38:00 Tiger Liu

After I released the use of coe_load_sql_profile.sql The script can solve the problem that the execution plan of the production system suddenly deteriorates , I happened to see another article the next day :《 Implementation plan :Oracle Of Profile Characteristics and SQL Stability of execution plan 》, The article is dedicated to sql profile Made an in-depth introduction , To understand SQL profile The principle of is very helpful . Because both the writer and the forwarder are big winners in the industry , Many fans , Many people should have read that article , Therefore, it is necessary to correct a minor flaw in the article , namely “SQL profile The execution plan cannot be fixed ” This conclusion is not accurate , Just a result under certain test conditions .

The following figure is the conclusion of the article :

Used by the author of the article Test case in , It should be possible to get such a result , But the conclusion is not complete , Will give the reader a misleading :SQL prfofile The execution plan cannot be fixed .

The above conclusion is that oracle Of sql tuning advisor Tool generated sql profile( Write only one opt_estimate One of them is hint), As an optimization tool , For such a SQL It is understandable not to be completely fixed . This also reminds us of DBA, use sql tuning advisor It's done sql profile It may not be able to execute the plan regularly .

I would like to add that : If in sql profile The complete outline data, The plan can be executed in a fixed way , For example, the following one SQL complete Hint Write the contents of profile:

/*+

BEGIN_OUTLINE_DATA

IGNORE_OPTIM_EMBEDDED_HINTS

OPTIMIZER_FEATURES_ENABLE('11.2.0.3')

DB_VERSION('11.2.0.3')

ALL_ROWS

OUTLINE_LEAF(@"SEL$1")

FULL(@"SEL

INDEX(@"SEL

LEADING(@"SEL

USE_NL(@"SEL

NLJ_BATCHING(@"SEL

END_OUTLINE_DATA

*/

This profile Yes you can specify SQL Which index to use , The association mode and order of tables .

Conclusion :

sql profile Can it be fixed sql Implementation plan of ?

The answer depends on where you are profile Used in hint What is the combination . Use the complete outline data The content can be fixed ; Use incomplete , Enlightening hint, Will not be fixed .

Use coe_sql_load_profile.sql The script will fix your SQL Implementation plan of ( Because it writes profile One of the contents of sql complete outline data Execution plan execution path ), Unless there's something special , If the index is not available 、 Insufficient parallel resources 、 Database related parameter changes, etc .

原网站

版权声明
本文为[Tiger Liu]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/173/202206221823300096.html