Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

core, graph, runtime: Add store.get_in_block #4540

Merged
merged 1 commit into from
Apr 21, 2023
Merged

Conversation

lutter
Copy link
Collaborator

@lutter lutter commented Apr 14, 2023

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 normal store.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, using store.get_in_block avoids this database roundtrip. For some subgraphs, these missed lookups can contribute significantly to the indexing time.

@@ -535,6 +536,13 @@ impl<C: Blockchain> WasmInstance<C> {
id,
field
);
link!(
"store.get_in_block",
store_get,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be store_get_in_block, right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh .. nice catch! Will fix that

Copy link
Contributor

@mangas mangas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check comment, otherwise looks good

@lutter lutter force-pushed the lutter/load-in-block branch from c8fccda to c99229c Compare April 21, 2023 16:01
@lutter lutter merged commit c99229c into master Apr 21, 2023
@lutter lutter deleted the lutter/load-in-block branch April 21, 2023 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants