Sql 调优顾问(接受配置文件)

发布于 2024-10-04 21:51:44 字数 597 浏览 3 评论 0原文

我已经为某些查询创建了 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

该查询的结果如下:

alt text

我不明白它是做什么的 :( 而且我想将此配置文件提示转换为更可读的 (/+ 提示/) 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:

alt text

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤单情人 2024-10-11 21:51:45

是的,您看到了那些大纲提示。

当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

面犯桃花 2024-10-11 21:51:45

根据此 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文