Oracle 风格的执行提示
当您为 Oracle 编写相当复杂的 SQL 时,迟早您将不得不应用奇怪的执行提示,因为 Oracle 似乎无法找出“最佳”执行计划本身。
http://download.oracle.com/docs/cd /B19306_01/server.102/b14211/hintsref.htm
现在这肯定不是 SQL 标准。但我仍然想知道,是否有任何其他 RDBMS 支持这些类型的提示,我真正的意思是“嵌入”在 SQL 中的提示?它们在语法上是否相似(即也位于 SELECT
关键字和第一个选定的 COLUMN
之间)?您是否知道比较各种 RDBMS 中提示的通用文档页面?
注意:我对这些 RDBMS 最感兴趣:Postgres、MySQL、HSQLDB、H2、Derby、SQLite、DB2、Sybase、SQL Server
When you write rather complex SQL for Oracle, sooner or later you will have to apply the odd execution hint because Oracle can't seem to figure out the "best" execution plan itself.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14211/hintsref.htm
Now this is certainly not a SQL standard. But still, I'm wondering, are there any other RDBMS that support these kinds of hints, and I really mean hints that are "embedded" in SQL? Are they similar, syntactically (i.e. also placed between the SELECT
keyword and the first selected COLUMN
)? Do you know of a general documentation page comparing hints in various RDBMS?
N.B: I'm mostly interested in these RDBMS: Postgres, MySQL, HSQLDB, H2, Derby, SQLite, DB2, Sybase, SQL Server
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我知道在 db2 中,计划是以某种方式固定的,而不是如何固定的。在 Oracle 11g 中,除了向查询添加提示之外,还有其他选项。这些是 SQLProfiles 和 SQLPlan Baselines,两者都非常强大。我刚刚完成了一个性能调优项目,相反,我们没有在代码中添加任何提示。
I know that in db2 the plans are made fixed in some way, not how. In Oracle 11g there are other options besides adding hints to queries. These are SQLProfiles and SQLPlan Baselines, both very powerful. I just finished a performance tuning project where we did not add even a single hint to the code, on the contrary.
您可以将 Oprimizer 提示 添加到任何 SQL Server 查询中
PLAN 子句 允许您为 Firebird 中的查询定义特定计划。
AFAIK,没有什么标准或接近它,但一般来说,你可以在很多 RDBM 中做到这一点,但不是全部。
You can add Oprimizer Hints to any SQL Server Query
The PLAN clause allows you to define a particular plan to your query in Firebird.
AFAIK, nothing standard nor close to it, but in general, you can do this in a lot of RDBM's, but not all.
我还想提醒您,如果您要与其他数据库平台进行某种比较,Oracle 中的提示完全不具有约束力。这就是说,如果 Oracle 愿意的话,它可以自由地忽略您的提示。
提示可能会有帮助,但我发现我很少再使用它们 - 至少与我在早期 Oracle 版本中使用旧优化器时相比是这样。那时,提示比现在更成为性能调整的主要内容。
I'd also remind you, if you are making some sort of comparison with other DB platforms, that hints in Oracle are entirely non-binding. Which is to say that Oracle is free to disregard your hint if it so chooses.
Hints can be helpfull but I find that I rarely use them anymore - at least not compared to the past when I was working with the older optimizers in earlier Oracle versions. Back then hints were much more of a staple to performance tuning than they are now.