Skip to content

Commit 343be90

Browse files
authored
Add docs for indexer hints (#583)
1 parent 23dd8c9 commit 343be90

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ description: Gravatar for Ethereum
101101
repository: https://github.com/graphprotocol/graph-tooling
102102
schema:
103103
file: ./schema.graphql
104+
indexerHints:
105+
prune: auto
104106
dataSources:
105107
- kind: ethereum/contract
106108
name: Gravity
@@ -150,6 +152,37 @@ The important entries to update for the manifest are:
150152

151153
- `features`: a list of all used [feature](#experimental-features) names.
152154

155+
- `indexerHints.prune`: Defines the retention of historical block data for a subgraph. Options include:
156+
157+
1. `"never"`: No pruning of historical data; retains the entire history.
158+
2. `"auto"`: Retains the minimum necessary history as set by the indexer, optimizing query performance.
159+
3. A specific number: Sets a custom limit on the number of historical blocks to retain.
160+
161+
```
162+
indexerHints:
163+
prune: auto
164+
```
165+
166+
> 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.
167+
168+
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.
169+
170+
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:
171+
172+
To retain a specific amount of historical data:
173+
174+
```
175+
indexerHints:
176+
prune: 1000 # Replace 1000 with the desired number of blocks to retain
177+
```
178+
179+
To preserve the complete history of entity states:
180+
181+
```
182+
indexerHints:
183+
prune: never
184+
```
185+
153186
- `dataSources.source`: the address of the smart contract the subgraph sources, and the ABI of the smart contract to use. The address is optional; omitting it allows to index matching events from all contracts.
154187
155188
- `dataSources.source.startBlock`: the optional number of the block that the data source starts indexing from. In most cases, we suggest using the block in which the contract was created.

0 commit comments

Comments
 (0)