Documentation forSQL Sentry

SQL Sentry Portal Top SQL

Introduction

The Top SQL view displays a unified picture of collected SQL statements. It's designed to help you quickly identify queries, applications, logins, and more that are causing the most waits, using the most resources, taking the most time, and putting the most load on your SQL Server.

Note:  Top SQL data is retained for 15 days by default. If you're using the SQL SentryPortal feature for SQL Sentry, this default value may be changed and is controlled by the Monitoring Service Settings.

Available Charts

The full viewing options for this card's charts are:

  • Queries ›
  • By App ›
  • By DB ›
  • By Host ›
  • By Login ›
  • Resources

Select the ellipsis button in the upper right for additional options such as reset, show/hide axis labels, and show/hide axes.

Show/hide axes has the following options:

  • Avg Duration (ms)
  • CPU Time (ms)
  • Exec Count
  • Reads Logical
  • Writes Logical
  • Reads Physical

On the options with the (chevron-right), additional choices similar to the above are available by selecting the symbol. For example, By App - Duration (ms) and Queries - Reads (P) are available chart options.

Queries

Select the (chevron-right) to view charts for:

  • CPU
  • Duration
  • Exec Count
  • Reads (L) - The default selection
  • Reads (P)
  • Writes (L)

The information displayed here is from query stats, procedure stats, and trace data.

Portal Top SQL tab Queries - Reads chart displaying query stats, procedure stats, and trace data.

Hover over an area in the chart to view more details about the queries:

Portal Top SQL tab Queries - Reads chart tooltip, displaying the values of multiple queries from a chart selection.

By App

Select the (chevron-right) to view charts for:

  • CPU
  • Duration
  • Exec Count
  • Reads (L) - The default selection
  • Writes (L)
  • Waits 

The information displayed here is from trace data.

Portal Top SQL tab By App - Reads charts displaying trace data.

Hover over an area on the chart to view more details about the applications:

Portal Top SQL By App - Reads chart tooltip displaying trace data per application for a specified time range.

By DB

Select the (chevron-right) to view charts for:

  • CPU
  • Duration
  • Exec Count
  • Reads (L) - The default selection
  • Reads (P)
  • Waits

Portal Top SQL tab By DB - Reads chart displaying Top SQL reads by database.

Hover over an area on the chart to view more details about the databases:

Portal Top SQL tab By DB - Reads chart tooltip displaying data per system database for a specific time range.

By Host

Select the (chevron-right) to view charts for:

  • CPU
  • Duration
  • Exec Count
  • Reads (L) - The default selection
  • Writes (P)
  • Waits

The information displayed here is from trace data.

Portal Top SQL tab By Host - Reads chart displaying trace data by host.

Hover over an area on the chart to view more details about hosts:

Portal Top SQL tab By Host - Reads chart tooltip displaying trace data by host for a specific time range.

By Login

Select the (chevron-right) to view charts for:

  • CPU
  • Duration
  • Exec Count
  • Reads (L) - The default selection
  • Writes (P)
  • Waits

The information displayed here is from trace data.

Portal Top SQL tab By Login - Reads chart displaying trace data.

Hover over an area on the chart to view more details about logins:

Portal Top SQL tab By Login - Reads chart tooltip displaying trace data for 3 logins for a specific time range.

Resources

View resource usage from Top SQL, based on query and procedure stats:

Portal Top SQL tab Resources chart based on query and procedure stats.

Hover over a point on the chart to view additional details about the resources being used:

Portal Top SQL tab Resources chart tooltip displaying Avg Duration (ms), Reads Logical, and CPU Time (ms).

Waits

Waits charts can be selected as a category from the Queries, By App, By DB, By Host, or By login options.

Waits Categories

Starting with Version 2023.3, view detailed Wait information by the following categories below.

Waits By App

View Waits By App to see the applications that were contributing to the wait(s), and the wait durations in milliseconds (ms).

Waits By DB

View Waits By DB to identify the database where the wait(s) occurred and see the overall wait durations in milliseconds (ms).

Waits By Host

View Waits By Host to identify the host where the wait(s) occurred and see the overall wait durations in milliseconds. 

Waits By Login

View Waits By Login to determine the login contributing to the wait(s) and see the overall wait durations in milliseconds (ms).

Note:Waits are recorded through the sqlserver.top.*category*.waits metrics and can be used to make custom charts with the Custom Charts feature.

Completed Queries

The Completed Queries tab lists all recorded completed queries matching the current filters across the selected time period. The Completed Queries tab is displayed on the Top SQL tab by default. There are two modes for this pane: Totals and Trace Events.

The Totals table lists all events for the active date range in a standard list format, sorted descending by Reads by default. The Totals table is activated whenever auto-refresh is enabled by selecting Play on the toolbar, which shows the events for the last hour with new events coming in automatically at the top of the list.

The Completed Queries tab also displays any recorded Statements, Query History, or Plan Diagram information for recorded Completed Queries.

Proc/Query stats

Click Proc/Query Stats to display the Proc/Query Stats tab. The Proc/Query Stats tab provides aggregate information for all procedures and queries matching the current filters. This area also provides insight into queries that run very quickly and in high volume.

The Proc/Query stats tab displays a Totals table and Statements table for all recorded Proc/Query stats. The Proc/Query Stats tab also displays any Query History, or Plan Diagram information for the Proc/Query Stats.

Totals

The Totals table displays by default in both the Completed Queries and Proc/Query Stats tabs. The Totalstable displays the text data and associated information such as database, duration, count, and CPU for the collected SQL statements (including procedure stats, query stats, and completed queries). This groups all like events together using a normalized version of the T-SQL with all variable parameters replaced, and it shows aggregates for each group. This enables you to quickly determine which events are responsible for the most CPU or IO activity for the active date range.

Note:  By default, the Totals table displays the top 15 queries by logical reads (descending ▼. For all tables, the arrow with the circle around it highlights by which column the data is sorted; ascending ▲ or descending ▼.

Click a recorded event to display all of the recorded instances of that event. Click the Trace Events toggle to display the Trace Events for your selection.

Totals Filtering

Use the search bar to further filter your Top SQL totals. Type your search parameters into the search bar and select enter to filter the Totals grid. 

Select the filter button on the Database category to filter by individual databases.

Select the databases that you want to filter by, and then select Apply to filter the Totals chart by your selection. 

Statements

Portal Top SQL tab Statements chart displaying additional information about Totals including plan diagrams, text data, parameters, and plan XML.

The Statements table displays additional information about Completed Queries or Proc/Query Stats where applicable, including plan diagrams, text data, parameters, and plan XML. The Statements table displays the statements that were collected with the associated completed query, procedure stats or query stats. It provides details on the key performance metrics that are associated with each component part of the larger query. This allows you to see which resources were consumed by which part of the batch.

Trace Events

Click the toggle in the Totals chart (on the Completed Queries tab to flip all totals and statements tables to the detailed Trace Events and Trace Events Statements tables on the Top SQL page and display details for any collected Trace Events such as RPC:Completed.

Trace Events Statements

Click the toggle in the Totals chart (on the Completed Queries tab to flip all totals and statements tables to the detailed Trace Events and Trace Events Statements tables and display statement details to any collected Trace Events such as SP:StmtCompleted.

Trace Event Waits

Select a Trace Event Wait (ms) link to open the Trace Event Waits chart for your selection.

The Trace Event Waits chart displays detailed information about the recorded Trace Event Wait including the text data, duration, waits (ms), reads, and writes.

Trace Event Filtering

Select the filter button on the desired category to filter by that category. For example, select the filter button for the hosts category, select the desired hosts, then select Apply to apply the filter to the Trace Events grid. 

Note:  You can filter by the Event Class, Host, Application Name, Database Name, Login, Error, and SPID categories.

Query History

Select a query or statement, then view the Query History for it. Query History displays a graphical representation of the selected query over a specified range of time. Query History provides information about the query execution plans, if and when they were changed, and how they impacted different resources. 

Query Event

Each triangle represents a Query Event.

Portal Top SQL tab Query History chart displaying the Query History for a selected statement across a specific time range.

Note:  The triangle colors represent execution plans. Triangles of the same color are using the same plan. If there is excessive plan drift (beyond 25 plans), then the 25 colors will start to be reused in the same order. Select a specific event to the Plan # represented.

Query Stats Sample

Each dot represents a Query Stats Sample or a Proc Stats Sample.

Portal Top SQL tab Query History chart displaying dots spread across the chart where each dot is a query stat sample.

Proc Stats Sample

Each dot represents a Proc Stats Sample or a Query Stats Sample.

Portal Top SQL tab Query History chart displaying dots spread across the chart where each dot is a proc stat sample.

Note:  The Mode for the Proc Stats Sample is set to Procedure.

Additional Options

Use the options below the chart to adjust the Grouping, Show, Metric, Mode, or Dates slider window.

  • Grouping
    • None
    • Hour
    • Day
    • Week
  • Show
    • Actual/Average
    • Totals
  • Metric
    • Duration
    • CPU
    • IO
  • Mode
    • Procedure
    • Statement
Note:  In Procedure mode, the chart reflects changes in the procedure stats (plan_handle), whereas Statement mode displays the changes in query stats (query_plan_hash).

Example with Grouping by Hour, ShowTotals, MetricCPU, and ModeStatement:

Portal Top SQL tab, Query History chart example with Grouping by Hour, Show Totals, Metric CPU, and Mode Statement applied.

An additional example with multiple plans represented:

Portal Top SQL tab Query History chart grouping multiple plans.

Additional Information:

Plan Diagram

Use the full screen button in the upper left to expand a larger plan, or use the Download Plan button to download the entire .sqlplan file.

Portal Top SQL tab Plan Diagram highlighting the full screen button, and the Download Plan button.

Note: 

  • Sometimes the plan XML may be populated, but there's not a statement that can be matched for the plan diagram. This can be caused by things like nested procedures or individual statements falling outside of the collection thresholds on their own. In this case, the plan diagram will display a message such as "The selected statement was not found in the plan XML. Download the full plan to view in Plan Explorer" and provide a Download Plan XML button.
  • If the Query History chart shows a disabled point (i.e. a gray triangle), then the plan diagram will display a message to indicate that there are no plans available (e.g. "There is no data to display").

Text Data

Use the Text Data tab to view a formatted and syntax color-coded copy of the statement.

Portal Top SQL tab, Text Data displaying a formatted and syntax color-coded copy of the selected SQL statement.

Parameters

Use the Parameters tab to view compiled values for statement parameters.

Portal Top SQL tab, Parameters tab displaying compiled values for the selected SQL Statement parameters.

Plan XML

Use the Plan XML tab to view or copy the ShowPlanXML output.

Portal Top SQL tab, Plan XML tab displaying the plan XML for a selected SQL statement and highlighting the Copy button.

Note:  The Copy button is only available when you are using HTTPS (requires an SSL certificate for your SQL Sentry Portal installation).