Bird
0
0

You want to design a scalable transaction history system for millions of users. Which approach best ensures fast retrieval of a user's transactions sorted by time?

hard📝 Trade-off Q15 of 15
LLD - Design — Splitwise (Expense Sharing)
You want to design a scalable transaction history system for millions of users. Which approach best ensures fast retrieval of a user's transactions sorted by time?
AStore transactions in separate files per day without indexing
BStore all transactions in one big list and scan it every time
CUse a database with an index on user ID and timestamp
DKeep transactions only in memory without persistence
Step-by-Step Solution
Solution:
  1. Step 1: Consider scalability and retrieval speed

    Scanning one big list or files without index is slow for millions of users.
  2. Step 2: Use database indexing on user ID and timestamp

    This allows fast queries to get transactions per user sorted by time efficiently.
  3. Step 3: Avoid in-memory only storage for persistence and scale

    Memory-only storage risks data loss and limits scale.
  4. Final Answer:

    Use a database with an index on user ID and timestamp -> Option C
  5. Quick Check:

    Indexing = fast retrieval at scale [OK]
Quick Trick: Index on user ID and timestamp for fast queries [OK]
Common Mistakes:
  • Scanning large lists for each query
  • Ignoring indexing benefits
  • Relying on memory-only storage

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LLD Quizzes