Pick the fix
Loading 200 playlists with their songs makes 201 queries. Best fix?
Hint 1 of 1
How many queries does a relation need?
Choose an answer, then open Show answer below to check it.
Show answer
Answer: A A PlaylistWithSongs class with @Embedded and @Relation, from a @Transaction DAO method
Correct. Room loads all songs for those playlists in one extra query.
Why not the others?
- B Run the 200 song queries in parallel. Still 200 queries, and SQLite serialises writes.
- C Cache the songs in memory. Hides the problem until the cache misses.
- D Increase the cursor window size. Doesn't reduce the number of queries.