Area: backend · Effort: S
What: Log all database queries exceeding 100ms with their SQL, parameters, and execution time, and expose a summary of the slowest queries.
Why: Slow queries are the most common performance bottleneck in web applications and are invisible without query logging. Early identification prevents them from becoming production incidents.
Acceptance Criteria:
- Queries > 100ms are logged at
WARN level with full SQL
- Queries > 1000ms are logged at
ERROR level and emit a metric
- A
GET /admin/slow-queries endpoint returns the top 10 slowest query types from the last 24 hours
- The slow query threshold is configurable via env var
Hints:
- Use TypeORM's
logger option with logSlowQueries: true and a custom logger class
backend/src/database/slow-query-logger.ts
- Aggregate slow query data in Redis with a 24-hour TTL
Area: backend · Effort: S
What: Log all database queries exceeding 100ms with their SQL, parameters, and execution time, and expose a summary of the slowest queries.
Why: Slow queries are the most common performance bottleneck in web applications and are invisible without query logging. Early identification prevents them from becoming production incidents.
Acceptance Criteria:
WARNlevel with full SQLERRORlevel and emit a metricGET /admin/slow-queriesendpoint returns the top 10 slowest query types from the last 24 hoursHints:
loggeroption withlogSlowQueries: trueand a custom logger classbackend/src/database/slow-query-logger.ts