The indexer was using SQL's skip for the pagination. The DB should scan the number of skipped rows, to get the page result. For the performance enhancement, we concluded that change the pagination method. Finding a particular row using an index and get the following n rows is much faster than using skip.
This commit uses firstEvaluatedKey and lastEvaluatedKey for the pagination in the BalanceHistory query. The BalanceHistory query will find a row using firstEvaluatedKey or lastEvaluatedKey and returns next n rows.
The indexer was using SQL's
skip
for the pagination. The DB should scan the number of skipped rows, to get the page result. For the performance enhancement, we concluded that change the pagination method. Finding a particular row using an index and get the followingn
rows is much faster than usingskip
.This commit uses
firstEvaluatedKey
andlastEvaluatedKey
for the pagination in the BalanceHistory query. The BalanceHistory query will find a row usingfirstEvaluatedKey
orlastEvaluatedKey
and returns nextn
rows.