View slow query details

In New Relic APM, when transaction traces are collected, there may be additional Slow query data available on the Databases page. This document explains what slow query data is, where to find it, and how to configure it.

Access to this feature depends on your subscription level.

Slow query data samples

When transaction traces are reported, the slow queries feature samples the slowest database queries in those traces and reports data about them on the Databases page. Slow query data can include:

View slow query data

To get a high-level overview of all your applications and services, use the entity explorer in New Relic One.

To see your slow query data:

In New Relic One
  1. Go to one.newrelic.com > Entity explorer > (select an app) > Explore performance > Databases.
  2. Select a database transaction.
  3. If available, select any available slow queries listed on the page.

For more information, see the documentation about navigating core UI components in New Relic One.

In New Relic APM
  1. Go to rpm.newrelic.com/apm > (select an app) > Monitoring > Databases.
  2. Select a database transaction.
  3. If available, select any available slow queries listed on the page.

If you do not see expected slow query data, follow the troubleshooting tips.

For more information, check out the New Relic University tutorial APM database dashboard. Or, go directly to the full online course APM for power users.

Configuration

In general, you can configure your slow query settings either of these ways:

Agent configuration gives you more options than server-side configuration does. How you choose to configure slow queries will depend on your own setup and preferences. For more information, see the documentation for the specific agent:

C SDK

You can report slow query traces for SQL databases only. For more information, see Instrument your application with the C SDK.

Go

Agent configuration options:

Java

Agent configuration:

You can also edit basic slow query settings via server-side configuration.

.NET

Agent configuration:

You can also edit basic slow query settings via server-side configuration.

Node.js

Agent configuration:

Server-side configuration of slow query data is not possible for the Node.js agent.

PHP

Agent configuration:

Server-side configuration is not possible for the PHP agent.

Python

Agent configuration:

You can also edit basic slow query settings via server-side configuration.

Ruby

Agent configuration:

If applicable for your application's agent language, you can also edit basic slow query settings by using server-side configuration.

Slow queries metrics

The slow queries list contains the following metrics:

Metric Description
Response time The average response time for the statements sampled.
Sample count The number of slow queries identified in the sample.

To view additional details, select an individual slow query:

Metric Description
Start time When the stack trace began collecting the data shown.
Max time The maximum time for all similar query statements in the sample.
Action The action or process invoking the query.
Query

The query that is being reported as slow. Depending on your configuration, some parts of the query may be obfuscated.

Stack trace Where in the code the statement was called.

For MySQL, New Relic provides a query analysis, which explains what happened in your query and what you might do to speed it up. Other databases display an explain plan whenever possible.

Troubleshooting: No slow query data

If you do not see slow query data, it may be for any of these reasons:

  • You do not have the required paid APM subscription level.
  • The slow query feature has been disabled.
  • The threshold is set to too high a duration and no slow queries are being reported.
  • The query obfuscation setting (usually record_sql or similar) may be set to Off.

To solve the problem, try adjusting the configuration options.

For more help

Recommendations for learning more: