CodeChain-io / CodeChain-io/codechain-indexer

Remove O(m) DB queries

未关闭
#316 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
21
派生
15
PR 合并指标
30 天内没有已合并 PR

描述

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.

贡献指南

这个仓库没有索引到贡献指南

调研方向

首先定位用于 Asset-type UTXO 查询、账户聚合、快照创建以及 web wallet 或 Hub 使用的 API 的 Indexer 入口点。检查这些查询当前如何扫描结果,并确定 API 和 consumer 需要进行哪些更改,以便分批获取结果且每批有明确上限;完成的标准是没有任何单个请求扫描全部 m 个 UTXO。

由索引模型根据 Issue 内容生成。

评估

技术栈
typescript
领域
api, databases, performance
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。