CodeChain-io/codechain-indexer

/tx API is not using the index correctly when filtering the result by the asset's type

Closed this issue · 4 comments

To query transactions using an asset type, the Indexer is using the assetTypeLogs table that has the assetType column. The result rows are ordered by the transactions' blockNumber and transactionIndex, and the DB should query all assetTypeLogs data and sort them.

Suggestion

Add an index to assetTypeLogs table with assetType, blockNumber, and transactionIndex columns.

There is the same problem when querying Transactions by an address. Indexer selects rows of AddressLog table and sorts them using the Transaction table's blockNumber column and transactionIndex column.

The web wallet queries the Transactions table by filtering both assetType and address data. We may need to create a table that has both assetType and address field.

API usages

  • /tx?assetType,page,itemsPerPage (console)
  • /tx?page,itemsPerPage,txTypes (explorer)
  • /tx?page,itemsPerPage,address (explorer)
  • /tx?page,itemsPerPage,assetType (explorer)
  • /tx?address,page,itemsPerPage (wallet)
  • /tx?address,assetType,page,itemsPerPage (wallet)

I'm working on adding an Address-AssetType-Log table.