开发者

Cheat sheet giving relative 'time costs' of various database operations?

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 p开发者_JS百科lain 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...


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜