<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    blog.Toby

      BlogJava :: 首頁(yè) :: 新隨筆 :: 聯(lián)系 :: 聚合  :: 管理 ::
      130 隨筆 :: 2 文章 :: 150 評(píng)論 :: 0 Trackbacks

    Best Practices for Troubleshooting Slow Running Queries

    In this article we will share some of the common reasons for slow-running queries and what your approach should be for identifying and fixing them. The best and the quickest way to address any slow running query should be by first preparing a Troubleshooting Checklist or Troubleshooting Guide and than by using it during slow running query situations. This way it can help any developer or DBA to easily and quickly narrow down the issue. (This troubleshooting guide or checklist should be posted on a central location from where all the DBA's / Developers of your team can access and update when required)

     

    Please note: If you experience something new which is not listed in the below list than you may update your TSG (Troubleshooting Guide) appropriately.

     

    Queries or updates that take more than the expected time to execute can be caused by a variety of reasons. Slow-running queries can be caused by performance problems related to your network or the computer where SQL Server is running. Slow-running queries can also be caused by problems with your physical database design and SQL Server configuration.

     

    Some of the most common reasons for slow-running queries and updates are:

     

    1) CPU could be causing the bottleneck

    2) Slow network communication (high latency).

    3) Insufficient memory in the server computer, or the memory is not properly configured for SQL Server instance.

    4) Insufficient useful statistics on indexed columns.

    5) Outdated statistics on indexed columns.

    6) Insufficient useful indexes.

    7) Lack of useful indexed views.

    8) Lack of useful data striping.

    9) Improper partitioning of data.

     

    Troubleshooting Checklist (covering most common scenarios)

     

    1) CPU could be causing the bottleneck

    What to do?

    One of the most common complaints I get is that SQL Server CPU started spiking excessively all of a sudden. A CPU bottleneck that happens suddenly and unexpectedly, without any changes or load on the server may be caused due to several reasons but some of the common reasons are:

     

    1) Non-optimal query plan,

    2) A poor SQL Server configuration,

    3) Improper Application/Database design,

    4) Insufficient hardware resources.

     

    Read more about “How to detect if SQL Server has bottleneck or not?”

     

     

    2) Could it be slow network communication (high latency).

    What to do?

    Investigate if the performance problem is related to a component other than queries? For example, is there a problem with network performance, do you see any latency issue, try copying the files across to measure the performance of your network. Also, try to identify if there are any other components that might be causing or contributing to performance degradation?

     

    What tool to use?

    The Windows System Monitor can be used to monitor the performance of SQL Server and non-SQL Server related components.

     

    Where to find more info?:

    http://msdn2.microsoft.com/en-us/library/ms191246.aspx

     

    3) Could it be Insufficient memory on the server computer, or the memory is not properly configured

    for SQL Server instance?

    What to do?

    If your investigation reveals that the performance issue is related to queries then Identify which query or set of queries are involved?

     

    What tool to use?

    You may use SQL Server Profiler to help identify the slow query or queries.

     

    Where to find more info?

    http://msdn2.microsoft.com/en-us/library/ms187929.aspx

     

    What’s next?

    After you have identified the slow-running query or queries, you can further analyze query performance by producing a query SHOWPLAN, which can be a text, XML, or graphical representation of the query execution plan that the query optimizer generates. You can produce query SHOWPLAN using:

    Ø Transact-SQL SET options,

    Ø SQL Server Management Studio, or

    Ø SQL Server Profiler.

     

    Where to find more info:

    How to use Transact-SQL SET options to display test and XML execution plans

    How to use SQL Server Management Studio to display graphical execution plans

    How to use SQL Server Profiler to display text and XML execution plans

     

    The information gathered by these tools would allow you to determine how a query is executed by the SQL Server query optimizer and which indexes are being used. This could help you determine if performance improvements can be made by rewriting the query, changing the indexes on the tables, or perhaps modifying the database design.

     

    4) Could it be due to Insufficient useful statistics on indexed columns.

    What to do?

    Investigate if the query was optimized with useful statistics or not? In SQL Server, statistics on the distribution of values in a column are created automatically on the indexed columns. They can also be created on non-indexed columns either manually using SQL Server Management Studio or CREATE STATISTICS statement, or automatically, if the AUTO_CREATE_STATISTICS database option is set to TRUE. These statistics can be used by the query processor to determine the optimal strategy for evaluating a query. Maintaining additional statistics on non-indexed columns involved in join operations can improve query performance.

     

    Alternatively, you can also monitor the query using SQL Server Profiler or the graphical execution plan in SQL Server Management Studio to determine if the query has enough statistics.

     

    What tools to use?

    Ø You can use Create Statistics, AUTO_CREATE_STATISTICS for creating and updating indexes. (Look at the below section for resource links)

    Ø You can also use SQL Server Profiler to determine if query has enough statistics

    Ø You can also use Graphical Execution plan from SQL Server Management studio to determine if query has enough statistics or not.

     

    Where to find more info?

    Create Statistics, Auto_Create_Statistics

    Details about Statistics and Indexes by Kalen Delaney

    Script to get the facts whether STATISTICS are required or not by Saleem Hakani

     

     

    5) Could it be due to outdated statistics on indexed columns.

    What to do?

     

    Check if the query statistics are up to date? Are the statistics automatically updated?

    SQL Server would automatically create and update query statistics on indexed columns (as long as automatic query statistic updating is not disabled). Additionally, statistics can be updated on non-indexed columns either manually, using SQL Server Management Studio or the UPDATE STATISTICS statement, or automatically, if the AUTO_UPDATE_STATISTICS database option is set to TRUE.

     

    Tip: Up-to-date statistics are not dependent upon date or time data. If no UPDATE operations have taken place, the query statistics are still up-to-date.

     

    What tool to use?

    You may use Auto_Create_Statistics property of the database to enable or disable the creation of statistics automatically.

     

    Where to find more info?

    You may use ALTER DATABASE option to enable AUTO_CREATE_STATISTICS on a database.

     

     

    6) Could it be due to Insufficient useful indexes.

    What to do?

    Investigate if suitable indexes are available? Investigate if adding one or more indexes can improve query performance?

     

    Where to find more info?

    General Index Design Guidelines

    Finding Missing Indexes

    Database Engine Tuning Advisor Reference

    Database Engine Tuning Advisor Tutorial

     

     

    7) Could it be the lack of useful indexed views.

    What to do?

    Identify if there are there any data or index hot spots? You may also consider using disk striping which can be implemented by using RAID (redundant array of independent disks) level 0 in which the data is distributed across multiple disk drives.

     

    Where to find more info?

    Using files and file groups

    Basics of RAID in SQL Server

    Different RAID levels in SQL Server

     

     

    8) Could it be due to lack of useful data striping.

    What to do?

    Check if the query optimizer has provided with the best opportunity to optimize a complex query?

     

    Where to find more info?

    Query Optimization Recommendations

     

    9) Could it be due to improper partitioning of data.

    What to do?

    Check if you have a large volume of data and if you do then you need to partition that data to achieve maximum performance from your queries. Data manageability is the main benefit of partitioning, but if your tables and indexes on them are partitioned similarly, partitioning can also improve query performance greatly.

     

    Where to find more info?

    Understanding SQL Server 2005 Data Partitioning

    Tuning the physical database design

     

    Once you perform all the above steps you should be able to resolve the performance issues for SQL Server queries.

    We will be adding more data to this article as it becomes available.

    posted on 2008-05-09 13:08 渠上月 閱讀(414) 評(píng)論(0)  編輯  收藏 所屬分類(lèi): other tips
    主站蜘蛛池模板: 日韩亚洲欧洲在线com91tv| 成人免费视频69| 国产福利免费视频| 日本黄页网址在线看免费不卡| 国产a视频精品免费观看| 三上悠亚电影全集免费 | 亚洲天堂在线播放| 亚洲精品人成在线观看| 亚洲AV福利天堂一区二区三 | 免费国产人做人视频在线观看| 国产精品久久久久影院免费| 免费在线视频一区| 亚洲一级特黄大片无码毛片 | 亚洲国产综合无码一区二区二三区| 亚洲阿v天堂在线2017免费| 亚洲一区二区精品视频| 亚洲一区二区三区影院| 亚洲国产成人私人影院| 亚洲人成在线精品| 亚洲精品永久在线观看| 日韩在线视频线视频免费网站| 成人网站免费大全日韩国产| 三级黄色在线免费观看| 99久久精品免费视频| 91香蕉视频免费| 免费A级毛片在线播放不收费| 国产亚洲精品影视在线产品| 久久久无码精品亚洲日韩蜜桃 | 久久亚洲中文字幕精品一区四| 亚洲精品成人片在线播放| 亚洲视频在线观看不卡| 亚洲乱亚洲乱妇24p| 国产成人无码精品久久久免费| 日本免费一区二区三区四区五六区| 免费观看AV片在线播放| 免费中文字幕不卡视频| 亚洲大成色www永久网站| 亚洲熟妇自偷自拍另欧美| 一级一级一片免费高清| 久久国产乱子伦免费精品| 日韩免费高清视频网站|