overfetchingQuery selects more fields than necessary
Query retrieves more data than needed — common with SELECT * or missing projections. Increases memory usage, serialization cost, and network transfer.
Common Causes
- —SELECT * without projection
- —Missing .select() in Mongoose
- —No Prisma select field list
- —GraphQL resolvers not using field selection
How to Fix
- 1.Use SELECT field1, field2 instead of SELECT *
- 2.Add Mongoose .select() calls
- 3.Use Prisma select object
- 4.Implement GraphQL field selection
Example
typescript
// BAD — fetches all user fields including password hash, large bio, etc.
const user = await User.findById(id);
// GOOD — only fetch what you need
const user = await User.findById(id).select('name email avatar createdAt');
// Prisma equivalent
const user = await prisma.user.findUnique({
where: { id },
select: { name: true, email: true, avatar: true, createdAt: true },
});