How to Check SQL Server Query Performance: Step-by-Step Guide

Download Article
Keep an eye on your database queries with the Query Store
Download Article

This How.com.vn teaches you how to to use the SQL Server Query Store to monitor the performance of your database queries.

Things You Should Know

  • You can enable the Query Store via the SQL Server Management Studio.
  • Use the - button on the Query Store to pull up a menu where you can check the top resource-consuming queries.
  • You can also click ″Check for regression in″ in the - menu to look for regressed queries.
Part 1
Part 1 of 3:

Enabling the Query Store

Download Article
  1. How.com.vn English: Step 1 Open the SQL Server Management Studio.
    You can use the Query Store feature of SQL Server to monitor your database for performance issues. This feature is included with SQL Server 2016 and later, but you'll need to enable it manually.[1]
  2. How.com.vn English: Step 2 Open Object Explorer.
    If you don’t see Object Explorer already, click the View menu at the top of the screen, then click Object Explorer.[2]
    Advertisement
  3. How.com.vn English: Step 3 Right-click the database you want to check.
    A menu will appear.[3]
    • The Query Store can’t be used to monitor the master or tempdb databases.
  4. How.com.vn English: Step 4 Click Properties.
  5. How.com.vn English: Step 5 Click Query Store.
    It’s on the Properties dialog box.
  6. How.com.vn English: Step 6 Select On under ″Operation Mode (Requested).
    ″ The Query Store will begin tracking all queries.
  7. How.com.vn English: Step 7 Refresh the database in the Object Explorer panel.
    This adds the Query Store folder to the panel.
  8. How.com.vn English: Step 8 Customize when the Query Store aggregates new data.
    The Query Store will aggregate new stats every 60 minutes by default. Here’s how to change the interval (using 15 minutes as an example):[4]
    • ALTER DATABASE <database_name>
    • SET QUERY_STORE (INTERVAL_LENGTH_MINUTES = 15);.
  9. Advertisement
Part 2
Part 2 of 3:

Finding the Top Resource-consuming Queries

Download Article
  1. How.com.vn English: Step 1 Click the - next to ″Query Store″ in the Object Explorer.
    This displays all Query Store options.
    • Use this method to find out which specific queries are using the most server resources.[5]
  2. How.com.vn English: Step 2 Click Top Resource Consuming Queries.
    This opens a graph that displays the 25 most resource-consuming queries in the database. These results are pretty broad, but you can further customize the graph to get more helpful information.[6]
  3. How.com.vn English: Step 3 Click Configure.
    It’s at the top-right corner of the report. A dialog window will appear.
  4. How.com.vn English: Step 4 Select your resource consumption criteria.
    In the top section (″Resource Consumption Criteria″), choose which resource you want to check (e.g., CPU Time, Memory Consumption), and the desired statistic (e.g., Avg, Total).
  5. How.com.vn English: Step 5 Select a time period.
    Under the ″Time Interval″ section, choose the time period for which you want to view results. You can select an option from the drop-down menu or insert specific dates into the provided boxes.
  6. How.com.vn English: Step 6 Choose how many results to see.
    To see all queries for the selected time period, click All under the ″Return″ header. To display a specific number of queries, select Top and enter a number (e.g. 10, 100).
    • If you want to stick to the top 25 worst offenders, there’s no need to make any changes under the ″Return″ header.
  7. How.com.vn English: Step 7 Click OK.
    The stats will now refresh to display what you want to see.
  8. How.com.vn English: Step 8 Adjust the view (optional).
    Use the small graph icons (the grid, chart, and bar graph) to view the results in various formats. These buttons are at the top-right corner of the results.
  9. Advertisement
Part 3
Part 3 of 3:

Checking for Regressed Queries

Download Article
  1. How.com.vn English: Step 1 Click the - next to ″Query Store″ in the Object Explorer.
    This displays all Query Store options.
    • Use this method to find specific queries that are performing more slowly than they used to.[7]
  2. How.com.vn English: Step 2 Click Regressed Queries.
    This opens the Regressed Queries panel, where you’ll find the queries and plans in the Query Store.[8]
  3. How.com.vn English: Step 3 Select a plan from the first drop-down menu.
    It’s the menu labeled ″Check for regression in″ above the top-left corner of the panel. Each of the plans will display a different graphical performance report for your queries.
    • For example, if you want to check for issues with in the amount of time it takes for queries to run, select Duration.
    • To see issues relating to RAM usage, select Memory Consumption.
  4. How.com.vn English: Step 4 Select a statistic from the second drop-down menu.
    This is the menu labeled ″Based on″ (to the right of the previous menu. This re-displays the results.
  5. Advertisement


Expert Q&A

Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
      Advertisement

      Tips

      Submit a Tip
      All tip submissions are carefully reviewed before being published
      Thanks for submitting a tip for review!

      About This Article

      How.com.vn English: Nicole Levine, MFA
      Written by:
      How.com.vn Technology Writer
      This article was co-authored by How.com.vn staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for How.com.vn. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions. This article has been viewed 38,911 times.
      How helpful is this?
      Co-authors: 4
      Updated: June 23, 2023
      Views: 38,911
      Categories: Databases
      Article SummaryX

      1. Enable the Query Store in Management Studio.
      2. Refresh the database.
      3. Expand the Query Store folder.
      4. Click Top Resource Consuming Queries.
      5. Click Configure.
      6. Set your parameters.
      7. Click OK.

      Did this summary help you?

      Thanks to all authors for creating a page that has been read 38,911 times.

      Is this article up to date?

      ⚠️ Disclaimer:

      Content from Wiki How English language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
      Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

      Notices:
      • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
      • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
      • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
      • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

      Advertisement