Sql 调优顾问(接受配置文件)
我已经为某些查询创建了 SQL 调整任务并执行了它。生成报告后,它建议我运行以下命令:
execute dbms_sqltune.accept_sql_profile(task_name => 'tuning_task_name',
replace => TRUE);
但是!我当然想知道这个配置文件是做什么的?!在互联网上搜索这个问题后,我发现了以下查询:
select
rat.attr1
from
sys.WRI$_ADV_TASKS tsk,
sys.WRI$_ADV_RATIONALE rat
where
tsk.name = 'tuning_task_name'
and rat.task_id = tsk.id
该查询的结果如下:
我不明白它是做什么的 :( 而且我想将此配置文件提示转换为更可读的 (/+ 提示/) sql 提示?
I have created sql tuning task for some query and executed it.After generating report,It recommends me to run the following command:
execute dbms_sqltune.accept_sql_profile(task_name => 'tuning_task_name',
replace => TRUE);
But! Of course I want to know what does this profile do?! and after searching this question on the internet I found the following query:
select
rat.attr1
from
sys.WRI$_ADV_TASKS tsk,
sys.WRI$_ADV_RATIONALE rat
where
tsk.name = 'tuning_task_name'
and rat.task_id = tsk.id
And the result of this query is the following:
I don't understand what does it do :( And also I want to convert this profile hints into the more readable (/+ hint/) sql hints?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的,您看到了那些大纲提示。
当oracle优化器解析这个SQL时,它们将被强制使用。因此,生成的执行计划会受到这些提示的影响。
如果您想在 SQL 中使用类似的提示,只需将它们复制到 SQL 中 SELECT 后面,用 /+/ 注释。请注意查询块名称,它们在不同的 SQL 中会发生变化。
以下是 Oracle SQL 提示的完整列表,供您参考。
http://www.hellodba.com/reader.php?ID= 208&lang=CN
http://www.hellodba.com/reader.php?ID= 220&lang=EN
希望这有帮助
Yes, you saw those outline hints.
They will be forced to be used when oracle optimizer parsing this SQL. Hence, the generated execution plan is affected by those hints.
If you want to use similar hints in you SQL, you just need simply copy them into you SQL where follows SELECT, commented by /+/. Be aware the Query Block names, they will be changed in different SQL.
Here is a full list of Oracle SQL hints for your reference.
http://www.hellodba.com/reader.php?ID=208&lang=EN
http://www.hellodba.com/reader.php?ID=220&lang=EN
Hope this helps
根据此 PDF 的第 24 页,看起来这些提示主要讲述了优化器调整不同对象的基数估计。我不确定为什么探查器要这样做;也许统计数据很糟糕,或者也许是为了强制制定更好的计划而制作了虚假统计数据?但也许理解概要文件的更好方法是比较之前和之后的解释计划。
Based on page 24 of this PDF it looks like these hints are mostly telling the optimizer to adjust the cardinality estimates for different objects. WHY the profiler is doing this I'm not sure; maybe the statistics are bad or maybe it's making fake statistics to force a better plan? But perhaps a better way to understand the profile is to compare the explain plan before and after.