Skip to content

Commit 94a1ae2

Browse files
azf20benface
andauthored
add more details on pruning (#668)
* add more details on pruning * prettier * fullstop Co-authored-by: Benoît Rouleau <benoit.rouleau@icloud.com> --------- Co-authored-by: Benoît Rouleau <benoit.rouleau@icloud.com>
1 parent 87c7fa5 commit 94a1ae2

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

website/pages/en/developing/creating-a-subgraph.mdx

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -752,6 +752,8 @@ dataSources:
752752

753753
The `indexerHints` setting in a subgraph's manifest provides directives for indexers on processing and managing a subgraph. It influences operational decisions across data handling, indexing strategies, and optimizations. Presently, it features the `prune` option for managing historical data retention or pruning.
754754

755+
> This feature is available from `specVersion: 1.0.0`
756+
755757
### Prune
756758

757759
`indexerHints.prune`: Defines the retention of historical block data for a subgraph. Options include:
@@ -765,9 +767,17 @@ The `indexerHints` setting in a subgraph's manifest provides directives for inde
765767
prune: auto
766768
```
767769

768-
> The term "history" in this context of subgraphs is about storing data that reflects the old states of mutable entities. This capability is essential for [time travel queries](/querying/graphql-api/#time-travel-queries), This feature enables querying the past states of these entities at specific blocks throughout the blockchain's history.
770+
> The term "history" in this context of subgraphs is about storing data that reflects the old states of mutable entities.
771+
772+
History as of a given block is required for:
773+
774+
- [Time travel queries](/querying/graphql-api/#time-travel-queries), which enable querying the past states of these entities at specific blocks throughout the subgraph's history
775+
- Using the subgraph as a [graft base](/developing/creating-a-subgraph/#grafting-onto-existing-subgraphs) in another subgraph, at that block
776+
- Rewinding the subgraph back to that block
777+
778+
If historical data as of the block has been pruned, the above capabilities will not be available.
769779

770-
Using `"auto"` is generally recommended as it maximizes query performance and is sufficient for most users who do not require access to extensive historical data.
780+
> Using `"auto"` is generally recommended as it maximizes query performance and is sufficient for most users who do not require access to extensive historical data.
771781

772782
For subgraphs leveraging [time travel queries](/querying/graphql-api/#time-travel-queries), it's advisable to either set a specific number of blocks for historical data retention or use `prune: never` to keep all historical entity states. Below are examples of how to configure both options in your subgraph's settings:
773783

@@ -785,6 +795,29 @@ indexerHints:
785795
prune: never
786796
```
787797

798+
You can check the earliest block (with historical state) for a given subgraph by querying the [Indexing Status API](/deploying/deploying-a-subgraph-to-hosted/#checking-subgraph-health):
799+
800+
```
801+
{
802+
indexingStatuses(subgraphs: ["Qm..."]) {
803+
subgraph
804+
synced
805+
health
806+
chains {
807+
earliestBlock {
808+
number
809+
}
810+
latestBlock {
811+
number
812+
}
813+
chainHeadBlock { number }
814+
}
815+
}
816+
}
817+
```
818+
819+
Note that the `earliestBlock` is the earliest block with historical data, which will be more recent than the `startBlock` specified in the manifest, if the subgraph has been pruned.
820+
788821
## Event Handlers
789822
790823
Event handlers in a subgraph react to specific events emitted by smart contracts on the blockchain and trigger handlers defined in the subgraph's manifest. This enables subgraphs to process and store event data according to defined logic.

0 commit comments

Comments
 (0)