You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Refactor Reports by Block and Services and enhancements (#62)
## Summary
- Added new table creation logic for
`staked_suppliers_by_block_and_services`,
`staked_apps_by_block_and_services`, and `relay_by_block_and_services`,
replacing unique index and upsert constraints to avoid unnecessary
overhead.
- Implemented retry utility for handling module accounts and integrated
it into `handleModuleAccounts`.
- Enhanced block report generation by running database functions in
parallel for performance improvements.
- Refined block processing in `handleBlock` to include timing logs for
profiling purposes.
## Issue
In **beta**, we have more than **10,000 services**. This caused the
indexer to take **over 30 seconds** to index a single block due to the
heavy load from reports by block and services.
The tables
- `staked_suppliers_by_block_and_services`
- `staked_apps_by_block_and_services`
- `relay_by_block_and_services`
were being created through **SubQL** (since they were defined in
`schema.graphql`). Because **historical data** was enabled, these tables
included the `_block_range` column, and SubQL automatically generated
compound indexes for each foreign key combined with `_block_range`.
However, historical data does **not** apply to these tables, since we
insert new records for every block. This means we don’t need the
`_block_range` column or the additional indexes created by SubQL.
With this change, the indexer now takes **around 5 seconds** to index a
block (down from 30+ seconds).
---
We also encountered an issue when fetching **module accounts**: queries
sometimes returned no results for the block being indexed. To address
this, we added a **retry mechanism** that keeps querying for module
accounts until they become available or the retry limit is reached.
## Type of change
Select one or more:
- [x] New feature, functionality or library
- [x] Bug fix
- [x] Code health or cleanup
- [ ] Documentation
- [ ] Other (specify)
## Sanity Checklist
- [x] I have tested my changes using the available tooling
- [x] I have commented my code
- [x] I have performed a self-review of my own code; both comments &
source code
- [ ] I create and reference any new tickets, if applicable
- [ ] I have left TODOs throughout the codebase, if applicable
0 commit comments