Slow query logging or monitoring is configured
Why it matters
Without slow query logging, a query that degrades from 50ms to 5000ms as the database grows is invisible until users file support tickets or error rates spike. By then, the query has been running slowly for hours or days. ISO 25010 time-behaviour requires that performance characteristics are observable and measurable; a database layer with no query timing instrumentation provides no signal for performance regressions introduced by new code, schema changes, or data volume growth.
Severity rationale
Low because slow query visibility affects detection speed rather than causing direct failures — performance degradation goes unnoticed longer, but the system continues to function.
Remediation
Configure Prisma event listeners or a pg query wrapper to log queries over 1 second. For production, send slow query events to your existing observability platform.
// lib/prisma.ts — log slow queries
const prisma = new PrismaClient({
log: [{ level: 'query', emit: 'event' }]
})
prisma.$on('query', (e) => {
if (e.duration > 1000) {
console.warn(`[slow-query] ${e.duration}ms: ${e.query}`)
// Sentry.captureMessage(`Slow query: ${e.duration}ms`, 'warning')
}
})
// Custom pg Pool timing wrapper
const origQuery = pool.query.bind(pool)
pool.query = async (...args: Parameters<typeof origQuery>) => {
const t = Date.now()
const result = await origQuery(...args)
const ms = Date.now() - t
if (ms > 1000) console.warn(`[slow-query] ${ms}ms`, args[0])
return result
}
For Postgres server-level logging (self-hosted): add log_min_duration_statement = 1000 to postgresql.conf.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Database Design & Operations Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- iso-25010:2011 · performance-efficiency.time-behaviour — Time Behaviour
Taxons
History
- 2026-04-18·v1.0.0·Initial import from database-design-operations·automated