Database and slow SQL dashboard

New Relic's Database feature shows individual database transactions as a table that you can sort. It also shows database operations, throughput, and response time as charts. If slow SQL information is available, it appears in the Slow SQL traces section at the bottom of the dashboard.

Note: The Slow SQL feature is for New Relic Pro and higher.

Procedures

To view information about database performance: From the New Relic menu bar, select Applications > (selected app) > Monitoring > Database.

Applications Monitoring Database
Applications > (selected app) > Monitoring > Database: Use this dashboard to view and sort detailed information about database performance and slow SQL (if applicable).

Use any of New Relic's standard user interface functions and dashboard features to drill down into detailed information. The Database dashboard has additional drill-down functions.

  • To view details about a individual database transactions or slow SQL transaction traces, select the individual row.
  • To close the transaction window and return to the Database dashboard, select the Close (X) button.
  • Admins: To delete all traces for your app permanently, select Delete all traces, and then select the confirmation prompt.

Tip: If you are doing general record cleanup, you may also want to delete transaction traces or error traces. This will remove potentially sensitive data while retaining your other application data (such as Apdex, deployment information, etc.).

Applications Monitoring Slow SQL
Applications > (selected app) > Monitoring > Database > (selected transaction): Here is an example of the details window for an individual database transaction. If slow SQL information is available, it appears at the bottom of the Database dashboard.

Slow SQL

Slow SQL samples are examples of the worst performing SQL on your site. Along with the SQL, New Relic collects the context and diagnostic information you need to fix your database performance issues.

To view slow SQL information:

  1. From the New Relic menu bar, select Applications > (selected app) > Monitoring > Database.
  2. From the Slow SQL traces section, select any row to view SQL details.
  3. To view additional details, select the Query analysis or Stack trace links.
  4. To exit the SQL information and return to the Database dashboard, select the Close (X) button.

Slow SQL Details
Applications > (selected app) > Monitoring > Database > (selected SQL transaction): Here is an example of the details window for an individual SQL trace transaction.

New Relic includes a stack trace and the start time. The stack trace shows you where in the code the statement was called, and the start time shows you when it was collected.

To diagnose the problem, New Relic shows the maximum time for all similar collected SQL statements and the total number of statements collected (the sample count). This is not the total number of times it was called in your application, but the number of times New Relic identified it as one of the slower SQL statements in your site. In addition, 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.

The agent captures all SQL 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 SQL statements during that minute.

Defining your SQL obfuscation preferences

To define your SQL obfuscation preferences:

  1. From the New Relic menu bar, select Applications > (selected app) > Settings > Application.
  2. Select Show advanced settings.
  3. Select your choices in the Transaction tracing settings for slow SQL.

Note: PHP users must use their .ini file, not the user interface, to define slow SQL settings.

Slow SQL troubleshooting

If you do not see slow SQL in the New Relic user interface, make sure:

  • Your New Relic account is Pro or higher.
  • The Slow SQL feature is enabled in your agent configuration. (From the New Relic menu bar, select Applications > (selected app) > Settings > Application, and verify that the Slow SQL checkbox option is selected.)
  • The transaction trace explain plan threshold is lower than the execution time of your SQL. (From the New Relic menu bar, select Applications > (selected app) > Settings > Application, and select Show advanced settings. Then verify the Transaction tracing settings for slow SQL.) Exception: PHP users must use their .ini file, not the user interface, to define slow SQL settings.

For more help

Additional documentation resources include:

If you need additional help, get support at support.newrelic.com.