Path

On your own database, choose one slow query, read why it is slow, apply a matching fix, and compare the numbers afterward.

Estimated time: 11 min

Find and fix a slow query

This path runs on your own Grafana Cloud stack and your own MySQL or PostgreSQL database. It tells you what to record. The slow-query guide assumes at least one database is already connected. Based on your diagnosis, apply the appropriate fix. After applying changes, confirm they worked.

If you have not connected a database yet, Introduction to monitoring databases: how to set it up for MySQL or PostgreSQL.

Here’s what to expect

When you complete this path, you’ll be able to:

  • Choose one query by duration, errors, and how often it runs
  • Read the explain plan and the table schema, and record what you found
  • Read the query samples and the wait events, and record what you found
  • Apply the fix that matches what you recorded
  • Compare duration, errors, and calls after you apply the fix

Before you begin

  • Database Observability is already receiving data from your database.
  • The database is MySQL 8.0 or later, or PostgreSQL 14 or later.
  • Your Grafana Cloud account has the Editor or Admin role.
  • You are allowed to change the database you pick, for example to add an index or to edit a query.

Troubleshooting

If you get stuck, we’ve got your back! Where appropriate, troubleshooting information is just a click away.

More to explore

We understand you might want to explore other capabilities not strictly on this path. We’ll provide you opportunities where it makes sense.

Are you ready?