Skip to content

Insights

The Insights tab on each database surfaces queries that took longer than 500 ms or returned an error. PerSQL automatically records them with the SQL text, duration, rows read/written, and any error message — so you have something concrete to fix instead of just a graph.

  • Every query whose durationMs > 500.
  • Every query whose status is error (regardless of duration).
  • Both /api/... console queries and /v1/... bearer-token queries.
  • Capped at the 500 most recent slow/errored rows per database; older rows are pruned by the minute-cron.

The first 1 500 chars of the SQL and the first 500 chars of the error message are kept. Rows are stored in your namespace’s slice of the control plane, not in the customer database itself.

Computed over the visible window (default: last 24 h):

  • Slow queries — count of recorded rows.
  • Errors — subset where status was error.
  • p50 / p95 / p99 / max duration — over the recorded rows.

Note: percentiles are over recorded (slow + errored) queries, not over all queries. A p95 = 800 ms means of the slow ones, 95 % finished within 800 ms. Fast queries are deliberately not recorded to keep the table small.

GET /api/namespaces/:ns/databases/:db/insights?hours=24

hours is clamped to 1..168.

{
summary: {
windowHours: 24,
slowCount: 42,
errorCount: 3,
p50DurationMs: 612,
p95DurationMs: 880,
p99DurationMs: 1020,
maxDurationMs: 1140
},
recent: [
{
id: "",
sqlText: "SELECT … FROM orders WHERE …",
durationMs: 612,
rowsRead: 12000,
rowsWritten: 0,
status: "ok",
errorMessage: null,
createdAt: "2026-05-04T11:32:00.000Z"
}
// …
]
}