Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add latest_tx_timestamp to the address_balance table #282

Open
r4mmer opened this issue Aug 29, 2022 · 0 comments
Open

Add latest_tx_timestamp to the address_balance table #282

r4mmer opened this issue Aug 29, 2022 · 0 comments
Assignees

Comments

@r4mmer
Copy link
Member

r4mmer commented Aug 29, 2022

Summary

We should add a column latest_tx_timestamp to the address_balance and update it whenever a new tx arrives (with the token for the address in question) or in the case of a re-org.

Motivation

The explorer-service queries for an address tokens ordered by most recent activity, the query made in this PR works very well but can be slow when the address has too many transactions since it requires the MAX(timestamp).
We would have 2 solutions, making an index on the timestamp column of the address_tx_history table or having the latest transaction timestamp "saved" on the address_balance table.

Both solutions can solve the issue but the first one still requires the explorer-service to make a sub-query on the address_tx_history table while the second get the same information in a more straightforward manner.

@r4mmer r4mmer self-assigned this Aug 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant