CodeChain-io / codechain-indexer

A blockchain data indexing tool for CodeChain
Apache License 2.0
21 stars 15 forks source link

Use an index to find rows in the next page in the AggsUTXO query #345

Closed majecty closed 5 years ago

majecty commented 5 years ago

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 AggsUTXO query. The AggsUTXO query will find a row using firstEvaluatedKey or lastEvaluatedKey and returns next n rows.

joojis commented 5 years ago

Would you fix the tests?

majecty commented 5 years ago

OK. I'll fix them.