English
Performance
This guide covers performance:
- High-impact levers
- Query shape example
- Repository and connection lifecycle
- Observability
High-impact levers
- Keep result sets small (
limit, pagination, cursor pagination). - Select only needed columns.
- Avoid unnecessary preloads and deep preload trees.
- Ensure indexes match filter + order-by columns.
- Use atomic batch operations (
createMany,saveMany, bulkupdate/delete) when suitable.
Query shape example
ts
const page = await repo.query()
.select(['id', 'email', 'status'])
.where('status', 'active')
.orderBy('id', 'asc')
.cursorPaginate({ perPage: 100, orderBy: ['id'] })Repository and connection lifecycle
- Reuse provider-managed DB connections.
- Use transaction-scoped repositories (
useTransaction) for grouped writes. - Avoid opening ad-hoc connections per request.
Observability
- Track p50/p95 query duration.
- Track rows returned per endpoint.
- Alert on unbounded queries and missing pagination.
- Benchmark hydration-heavy endpoints with realistic datasets.