core, graph, runtime: Add store.get_in_block #4540
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This adds a new host fn
get_in_block
that will only look for entities that have been created or updated in the current block. This can improve indexing performance quite a bit if it is known that a certain entity has to have been created in the same block.A typical situation for this is that one handler creates a
Transaction
from some on-chain event, and a later handler wants to access this transaction if it exists. In the case where the transaction does not exist, a normalstore.get
will have to go to the database just to find out that the entity does not exist; if the subgraph author already knows that the entity must have been created in the same block, usingstore.get_in_block
avoids this database roundtrip. For some subgraphs, these missed lookups can contribute significantly to the indexing time.