Bài viết
Chia sẻ kiến thức của bạn.
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
Câu trả lời
1The 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:
-
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.
-
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
ortotalValueLocked
. 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.
Bạn có biết câu trả lời không?
Hãy đăng nhập và chia sẻ nó.
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.
Kiếm phần của bạn từ 1000 Sui
Tích lũy điểm danh tiếng và nhận phần thưởng khi giúp cộng đồng Sui phát triển.