Performance Tuning SQL - How?

后端 未结 4 2147
终归单人心
终归单人心 2020-12-25 09:21

How does one performance tune a SQL Query?

  • What tricks/tools/concepts can be used to change the performance of a SQL Query?
  • How can t
相关标签:
4条回答
  • 2020-12-25 09:59

    Here are some basic steps which we can follow to increase the performance:

    1. Check for indexes in pk and fk for the tables involved if it is still taking time index the columns present in the query.
    2. All indexes are modified after every operation so kindly do not index each and every column
    3. Before batch insertion delete the indexes and then recreate the indexes.
    4. Select sparingly
    5. Use if exists instead of count
    6. Before accusing dba first check network connections
    0 讨论(0)
  • 2020-12-25 10:02

    I really like the book "Professional SQL Server 2005 Performance Tuning" to answer this. It's Wiley/Wrox, and no, I'm not an author, heh. But it explains a lot of the things you ask for here, plus hardware issues.

    But yes, this question is way, way beyond the scope of something that can be answered in a comment box like this one.

    0 讨论(0)
  • 2020-12-25 10:22

    Writing sargable queries is one of the things needed, if you don't write sargable queries then the optimizer can't take advantage of the indexes. Here is one example Only In A Database Can You Get 1000% + Improvement By Changing A Few Lines Of Code this query went from over 24 hours to 36 seconds

    0 讨论(0)
  • 2020-12-25 10:23

    Of course you also need to know the difference between these 3 join

    loop join, hash join, merge join

    see here: http://msdn.microsoft.com/en-us/library/ms173815.aspx

    0 讨论(0)
提交回复
热议问题