System Design · Middle · Question 44 of 75
Why can returning totalCount in every list response be expensive?
- ✓Correct answer: An exact
COUNT(*)with filters loads the database - 2JSON can't transmit large numbers
- 3The browser can't display a number over a million
Explanation
An infinite feed doesn't need an exact number - hasNextPage is enough. If the number matters, use an approximate estimate, cache the count, or compute it separately and less often.