CodeChain-io / CodeChain-io/codechain-indexer

Remove O(m) DB queries

Abierto
#316 1 comentario 0 reacciones 0 asignados Ver en GitHub
Lenguaje dominante
TypeScript
Estrellas
21
Forks
15
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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.

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Línea de trabajo

Start by locating the Indexer entry points for Asset-type UTXO queries, account aggregation, snapshot creation, and the APIs used by the web wallet or Hub. Review how these queries currently scan results and determine the API and consumer changes needed so results are fetched in bounded batches; done means no single request scans all m UTXOs.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
typescript
Área
api, databases, performance
Tipo de issue
Nueva funcionalidad
Dificultad
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Necesita aclaración
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.