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.

About slow query data

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 see your slow query data:

  1. Go to rpm.newrelic.com/apm > (select an app) > Monitoring > Databases.
  2. Select a database transaction.
  3. View slow queries (if present) by looking under Slow queries section at the bottom of the page.

If you do not see expected slow query data, see Troubleshooting.

For details about slow query data, see Slow query metrics.

Configuration

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

  • Agent configuration
  • Server-side configuration (not available for Go and PHP, and slow query config not available for Node.js)

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 agent-specific instructions, select an agent:

Go

Agent configuration options:

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

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:

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

If you expect to see slow query data but do not, see Troubleshooting.

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.

Select an individual slow query to view details for that 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.

New Relic collects the explain plan whenever possible. (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.)

Troubleshooting: No slow query data

If you do not see slow query data, it may be for one 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.

See Configuration for more about adjusting these configuration options.

For more help

Recommendations for learning more: