CodeChain-io / CodeChain-io/codechain-indexer
Remove O(m) DB queries
- Ngôn ngữ chính
- TypeScript
- Star
- 21
- Fork
- 15
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
When querying UTXOs using Asset type, aggregating UTXOs by account, and creating a snapshot, the Indexer scans all the UTXOs that have a specific account or a specific asset type.
When a user opens a CodeChain web wallet, wallet requests the total amount of assets that the user has to the Indexer. Indexer sends a query that scans all the UTXOs that the user has. If the number of UTXOs that the user has is `m`, the upper bound of the query is `O(m)`.
### How to solve
Make APIs return sub results that read k rows in the DB. The Web wallet or Hub should request the maximum `[n/k]` number of API calls to get all the results. The upper bound of each query is O(k*log m). Then there won't be a single slow query that consumes all the resources(CPU, Memory, disk I/O) in the DB.
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Hướng nghiên cứu
Bắt đầu bằng cách xác định các entry point của Indexer cho các truy vấn Asset-type UTXO, việc tổng hợp tài khoản, việc tạo snapshot và các API được web wallet hoặc Hub sử dụng. Xem xét cách các truy vấn này hiện quét các kết quả và xác định những thay đổi cần thiết đối với API và consumer để các kết quả được lấy theo các batch có giới hạn; hoàn thành có nghĩa là không có request đơn lẻ nào quét toàn bộ m UTXOs.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- typescript
- Lĩnh vực
- api, databases, performance
- Loại issue
- Tính năng
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100