备忘单给出了相对“时间成本”各种数据库操作?
这可能被认为是一个奇怪的问题 - 但我正在寻找一个“备忘单”来描述(例如)各种数据库操作的“昂贵”程度。
我正在寻找一种理论理解(也许有统计数据支持)......例如,我可以猜测带有 order by 语句的选择操作比普通的选择操作慢。
但我听说 JOIN 是最“昂贵”的,但我不确定这一点......所以最好能得到一些证明......
This might be considered an odd question - but i'm looking for a "cheat sheet" that describes (for example) how "expensive" various database operations are.
I'm looking for a theoretical understanding (perhaps backed by statistical data).... for example I can guess that a select operation with an order by statement is slower than a plain select one.
But i've heard that JOINs are the moste "expensive" ones but i'm not sure of that... so it would be good to get some proof of that...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不确定我是否见过这样的物品。这是一个相当复杂的领域,如果本地便宜的操作阻止在整个查询中使用更便宜的策略,那么它可能不是全局最优的。
例如,表扫描应该是昂贵的,但如果需要选择超过百分之几的记录,则表扫描通常是大型表上最便宜的操作。这是因为表扫描主要由顺序 I/O 组成,与(例如)书签操作可能使用的大量随机 I/O 相比,它可以相对有效地覆盖大量流数据。
查询优化教程确实太大了,无法放入 stackoverflow 帖子中(至少在我有时间的情况下),但是网络上有很多资源,并且有很多印刷书籍可以很好地处理它。尽管这些原则通常适用于跨平台,但它在某种程度上也依赖于平台。
SQL Server 是一个很好的实验系统,因为它附带的前端工具具有查询计划可视化功能,即使在免费的“快速”版本上也是如此。
Not sure I've ever seen such an item. It's quite a complex field, and a locally cheap operation might not be globally optimal if it precludes a cheaper strategy from being used across the whole query.
For example, table scans are supposed to be expensive, but are often the cheapest operation on a large table if more than a few percent of records need to be selected. This is because a table scan is largely composed of sequential I/O, which can cover a large volume of streamed data relatively efficiently in comparison to a large number of random I/Os that (for example) a bookmarking operation might use.
A query optimisation tutorial is really too big to fit into a stackoverflow posting (at least in the time I have available) but there are many resources on the web, and quite a few print books that give it a good treatment. It is also somewhat platform dependent, although the principles often apply across platforms.
SQL Server is a good system to experiment with as the front-end tool shipped with it has a query plan visualisation feature, even on the free 'express' versions.