The Slow Queries details pane is part of New Relic APM's Databases page. The Slow Queries details pane shows the time the transaction took, the query, and a trace for the query. If slow queries have been recorded, they appear in the Slow Queries section at the bottom of the Databases page.
The agent captures all queries that exceed the transaction trace explain plan threshold. The agent aggregates similar statements together but only keeps the details for the worst of each similar statement. Every minute, the agent sends several samples to the New Relic service. These represent the worst performing query statements during that minute.
Access to this feature depends on your subscription level.
View the Slow Queries page
The Slow Queries feature samples the worst performing database queries on your site. Along with the query, New Relic collects the context and diagnostic information you need to fix your database performance issues. Slow Queries are part of the Databases page.
If slow queries have been recorded, they appear in the Slow Queries section at the bottom of the Databases page. In addition, if your APM agent supports host and instance level details, you can view both the query details and the specific instance where the query was executed
To view information on a slow query:
- From the New Relic menu bar, select APM > (selected app) > Monitoring > Databases.
- From the Slow Queries table, select any row to view the query details.
If there are no slow queries to report, the Slow Queries table will not be visible.
Slow Queries metrics
The Slow Queries list contains the following metrics:
|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:
|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.|
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. In 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.
Defining your query obfuscation preferences
To define your query obfuscation preferences:
- From the New Relic menu bar, select APM > (selected app) > Settings > Application.
- Select fa-ellipsis-hShow advanced settings (on the right side of the page).
- Select your choices in the Transaction tracing settings for slow queries.
For the PHP agent, use the
Slow query troubleshooting
If you do not see slow queries in the New Relic user interface, make sure:
|Is your New Relic account a paid account type?|
|Is the Slow Query feature is enabled in your agent configuration?||
To check your configuration:
|Is the transaction trace explain plan threshold lower than the execution time of your queries?||
To check your threshold:
For more help
Additional documentation resources include:
- Database and Slow Query page (an overview of the Databases page, which includes Slow Queries.)
- Database analysis report (how to use the report available in the UI to compare the amount of time spent in throughput (requests per minute or rpm), total time in the operation, and average time to execute it)
- Transaction Traces (overview of transaction traces)
- Security options for transaction traces (queries, HTTPS parameters, and customization options for enhanced security)
- Database queries (viewing the Database queries tab for a transaction trace)