The Graph.

帖子

分享您的知识。

TheGraph Mod QST.
Mar 29, 2024
专家问答

Relational database when using subgraph for event indexing

I'm exploring the use of subgraph to index events in my project. I'm wondering if setting up a relational database is still necessary in this scenario. Would the subgraph alone be sufficient for efficient event indexing, or should I consider incorporating a relational database as well? I'd appreciate any insights or recommendations from the community.

  • The Graph
  • GraphQL
  • Indexers
  • Subgraph
0
1
分享
评论
.

答案

1
TheGraph Mod ANS.
Mar 29 2024, 23:35

The subgraph serves as a relational database in this context. Here are a couple of approaches you can take when storing events as entities or building more descriptive entities to transform the data:

  1. Storing events as entities:

    • Each event can be stored as a separate entity, allowing you to easily query and retrieve specific events.
    • This approach provides a straightforward representation of the data, but it may result in a large number of entities depending on the volume of events.
  2. Building descriptive entities:

    • Instead of storing events as individual entities, you can create more descriptive entities that aggregate and transform the data.
    • For example, you can create a "protocol" entity that includes counters for activeAccounts or totalValueLocked. This entity can be updated based on the events received, providing a more concise representation of the data.
    • By building descriptive entities, you can simplify the querying process and potentially reduce the number of entities in your subgraph.

Both approaches have their own advantages and considerations, so it's important to choose the one that best suits your specific use case. Additionally, you may need to consider the scalability and performance implications of each approach, especially when dealing with a large volume of events.

0
官方答案
评论
.

你知道答案吗?

请登录并分享。

The Graph is a decentralized protocol for indexing and querying blockchain data. The Graph makes it possible to query data that is difficult to query directly.

259帖子259答案
Sui.X.Peera.

赚取你的 1000 Sui 份额

获取声誉积分,并因帮助 Sui 社区成长而获得奖励。