-
-
Notifications
You must be signed in to change notification settings - Fork 78
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 pool_id
and an index by the pool_id
and height
fields in block
table
#756
Comments
Mhh... After looking into this request, I have some doubts:
So, it's not really clear what/why we need here/it |
This query does not show which recip_id forged the block. For example, |
Query to get recip_id and its last forged block:
In Django, this query looks like this:
What this query does (conditionally):
Such a query is slow, and the simplest solution is to add the recip_id field to the Block table (https://stackoverflow.com/questions/45437096/django-filter-by-annotated-field-is-too-slow) |
Thanks for detailed explanations... |
If this doesn't affect the running of the node itself, I vote against it. Another index will increase the database size. Maybe not significantly at first but we want to ensure it grows as slowly as possible to ensure long term viability. This is something that could be offloaded into the explorer database. Run a one time query on the node and store the results in the explorer database where you can index however you like. That'll get you your desired speed while maintaining the node database without an extra index. I realize this may be inconvenient but using the explorer database is really not a difficult solution. Additionally, the duplicate data means we have now lowered the normalization level, ensuring we have an opportunity to have conflicting data. If you use a calculated field, you avoid the duplicate data but you don't gain the speed benefit you desire. |
Your proposed implementation is working on my test explorer now. And this is the most optimal solution so far. |
can I close this? @Antoninich |
Now, in order to find out which block has which pool, have to query two tables
block
andreward_recip_assign
. If you create a query to theblock
table and annotaterecip_id
from thereward_recip_assign
table, then filtering by the annotated field is very slow, because it is not indexed.This is required for the Pool section (https://explorer.it24.pw/pools/ or https://explorer.notallmine.net/pools/).
And make indexing by the pool_id and height fields with reverse sorting. For example,
CREATE INDEX
block_pool_id_height_idxON
block(
pool_id,
heightDESC);
The text was updated successfully, but these errors were encountered: