What are the downsides of REST, including over-fetching, under-fetching, and the N+1 problem?
Last updated
Over-fetching: endpoints return more fields than needed (mitigate with sparse fieldsets like
?fields=name,email). Under-fetching: one call isn't enough, forcing extra round trips (mitigate with aggregate or embedded endpoints).N+1 problem: fetching a list, then one extra request or DB query per item. Fix with batch endpoints, eager loading/joins, or a dataloader.
All stem from the server fixing response shape, which also causes versioning churn. GraphQL or BFF (backend-for-frontend) layers often address this.
- https://docs.aws.amazon.com/appsync/latest/devguide/why-use-graphql.html
- https://www.freecodecamp.org/news/how-to-use-graphql-in-flutter-a-handbook-for-developers/
- https://docs.aws.amazon.com/appsync/latest/devguide/comparing-rest-graphql.html
- https://dev.to/leonardkachi/apis-rest-graphql-websockets-api-gateway-authentication-rate-limiting-and-versioning-35ke
- https://dev.to/leonardkachi/aws-vpc-3mhb
- https://blog.stackademic.com/what-is-over-fetching-and-under-fetching-in-apis-96628332c64c
- https://medium.com/@rajputmukesh748/what-is-over-fetching-and-under-fetching-in-apis-96628332c64c
- https://medium.com/@bvsahane89/understanding-the-n-1-problem-in-rest-api-design-causes-consequences-and-solutions-28d9d3d47860