开发者

What are the principles for writing an optimized sql query? [closed]

开发者_StackOverflow社区 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 11 years ago.

If somebody has best Practices for Query Optimization, please write it as an answer.


Last year I followed a series of videos by Andy Warren which I would highly recommend:

  • Performance Tuning Puzzle - Part 1
  • Performance Tuning Puzzle - Part 2
  • Performance Tuning Puzzle - Part 3

Those are good, and he has a bunch more videos with great performance tips.


learn how to analyze the execution plan.


  1. Pull data from the smallest tables first, then join to the larger ones.
  2. Use INNER JOIN where you can.
  3. Put conditions into the JOIN where possible, rather than in the WHERE clause.

These are very rough, not exhaustive, but rules of thumb that help me day-to-day.


Check the MSDN blog of the Query optimization team and this list, both refers to SQL-Server

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜