Performance: CRUD with Prisma
MEDIUM IMPACT
This concept affects server response time and database query efficiency, impacting how fast the page can load or update data.
async findAll(page = 1, limit = 10) { return await this.prisma.user.findMany({ skip: (page - 1) * limit, take: limit }); }
async findAll() { return await this.prisma.user.findMany(); }
| Pattern | Database Queries | Server Response Time | Network Payload | Verdict |
|---|---|---|---|---|
| Fetch all without pagination | 1 large query | High due to large data | Large JSON payload | [X] Bad |
| Fetch with pagination | 1 small query | Low and predictable | Small JSON payload | [OK] Good |
| Update with read then update | 2 queries | Higher latency | Minimal payload | [X] Bad |
| Update with single query | 1 query | Lower latency | Minimal payload | [OK] Good |
| Delete with read then delete | 2 queries | Higher latency | Minimal payload | [X] Bad |
| Delete with single query | 1 query | Lower latency | Minimal payload | [OK] Good |