Допис
Діліться своїми знаннями.
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
Відповіді
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.
Ви знаєте відповідь?
Будь ласка, увійдіть та поділіться нею.
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.
Зароби свою частку з 1000 Sui
Заробляй бали репутації та отримуй винагороди за допомогу в розвитку спільноти Sui.