API performance Level 1 This level · 3 of 10
Easy java backend

Paginate and return only needed fields

The 30 second answer

I never return unbounded lists. Every collection endpoint is paginated with a sensible maximum page size, and the response includes only the fields the client needs. Smaller responses mean less database work, less serialization, and less network time, which matters most for mobile clients. Field selection or separate summary and detail endpoints keep payloads small without forcing clients to make extra calls.

Could you say this in an interview?

Smaller payloads mean less serialization and transfer time, and pagination caps the work per request (see keyset pagination in 2.8). Editor's note: expose a fields parameter or a dedicated DTO rather than the full entity.

Sources (1)
  1. Use The Index, Luke: Paging Through Resultsuse-the-index-luke.com
Previous
Next