-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Fix performance of address page for validators #2908
Conversation
2f4fc7e
to
70147b7
Compare
Pull Request Test Coverage Report for Build c4f55590-f3fc-42d0-b14b-d3adfdbb3946
💛 - Coveralls |
0e7ac1b
to
a268c0f
Compare
a268c0f
to
e167d27
Compare
@ayrat555 I found a way how to improve performance of the page for validators without limits:
need to be reviewed again |
#2306
Motivation
The issue with the performance of address's page is related only to validators and the slowest part is the query to get block rewards for validators. The problem is that some validators changed their payout keys. It means that once upon a time they have been getting rewards on their mining key and after the change, they began to get rewards to their payout key. Thus, opening the address page for mining key of validator somewhere deeply in
block_rewards
table we have rows for the rewards for that mining key but since we ordering by block numbers in descending order, the query works very slow to get 50 rows. I think we should get rewards only for the latest blocks. Let's say the last 2000 blocks - it is enough to keep track of rewards on the first 3 pages of chain with 20 validators. I doubt someone will look deeper than 2nd page looking for rewards.Changelog
The query that slows down address page:
it is suggested to change it to:
Before:
After:
UPDATE 2019-12-12
I found a way how to increase the performance of the validators' address' page even without limiting the number of taking to account rewards. The idea is to get the range of blocks where transactions found for this page of the transactions' list in the pagination and show rewards, that are in the block's range. Even despite that fact that page will wait retrieving of this blocks' range first to proceed with rewards query, page works dramatically faster.
Checklist for your Pull Request (PR)
CHANGELOG.md
with this PRmaster
in the Version column. Changes will be reflected in this table: https://docs.blockscout.com/for-developers/information-and-settings/env-variables.