Monitor
Find slow database queries
Spot database statements that take 250 ms or longer in your app's logs, with their shape but never their values.
When a database statement in your app takes 250 milliseconds or longer, Ahamo writes a Slow query line to the
app's logs. The line shows the kind of statement, the table, the time and the number of rows, and the statement's
shape with every value replaced by ?. It is on for every app, in the preview and when published.
When to use it
- A screen loads slowly and you want to know whether the database is the cause.
- You want to see which query to speed up before more people use the app.
How to use it
- Open Runtime, choose the environment tab, and open Logs.
- Look for lines marked Slow query. A line reads like
Slow select on bookings: 412 ms, 1,250 rows · SELECT * FROM bookings WHERE owner_id = ? [3f9a…].
The short code at the end stays the same each time the same statement runs, so you can tell repeats apart.
Ask the build AI to fix it.
The logs show a slow select on bookings (about 400 ms). Add an index or change the query so the bookings list loads faster, and explain the change.
An app published before this feature arrived shows slow queries after its next publish.
Plans and limits
The same on every plan.
| Rule | Value |
|---|---|
| Logged when a statement takes | 250 ms or more |
| Lines at most | 30 a minute; the next line says how many were left out |
| Not logged | Migrations and seed data |
| Statement shape | Values removed, cut at 300 characters |
| Kept | Like the app's other logs, the Logs page shows the last hour |
Troubleshooting
No slow query lines. Either nothing took 250 ms, or the app was last published before this feature, so publish again.
"(… more slow statements not shown)". More than 30 slow statements ran in a minute. Fix the most frequent one first; the rest often share its cause.