replace getAllUsers by getAllUserIds

This commit is contained in:
Jens Petersen 2014-06-23 14:00:53 +09:00
parent da1525d897
commit 53cf6095fa

View File

@ -9,9 +9,9 @@ getAllUsernames = do
getUsernameById userId
```
The `IO` version of this code would perform one data fetch for `getAllUsers`, then another for each call to `getUsernameById`; assuming each one is implemented with something like the SQL `select` statement, that means “N+1 selects”.
The `IO` version of this code would perform one data fetch for `getAllUserIds`, then another for each call to `getUsernameById`; assuming each one is implemented with something like the SQL `select` statement, that means “N+1 selects”.
But Haxl does not suffer from this problem. Using *this very code*, the Haxl implementation will perform *exactly two* data fetches: one to `getAllUsers` and one with all the `getUsernameById` calls batched together.
But Haxl does not suffer from this problem. Using *this very code*, the Haxl implementation will perform *exactly two* data fetches: one to `getAllUserIds` and one with all the `getUsernameById` calls batched together.
First, a dash of boilerplate: