Shiyas pfp
Shiyas
@shiyasmohd
Are you building subgraphs on @graphprotocol? Here are 2 simple tips to boost your subgraph's indexing and querying performance πŸ”₯ A small thread 🧡
1 reply
0 recast
0 reaction

Shiyas pfp
Shiyas
@shiyasmohd
1. Mark entities as immutable whenever possible If you will not edit the entity in the future. In schema.graphql, you can mark entities as immutable as given below.
1 reply
0 recast
0 reaction

Shiyas pfp
Shiyas
@shiyasmohd
How does it make a difference? When entity types are marked as immutable, graph-node uses database indexes that are much cheaper to build and maintain than mutable entities.
1 reply
0 recast
0 reaction

Shiyas pfp
Shiyas
@shiyasmohd
2. Use type Bytes for id in entities rather than type ID How does it make a difference? In simple words, type ID takes twice the space of Bytes and comparison of strings in Bytes is much cheaper than in type ID.
1 reply
0 recast
0 reaction

Shiyas pfp
Shiyas
@shiyasmohd
This performance measurement was done in a controlled environment where 4 subgraphs were deployed. base - immutable ❌ & bytes ❌ immutable - immutable βœ… & bytes ❌ bytes - immutable ❌ & bytes βœ… both - immutable βœ… & bytes βœ…
1 reply
0 recast
0 reaction

Shiyas pfp
Shiyas
@shiyasmohd
These 2 tips are very small changes, but they will greatly impact the subgraph's indexing and querying performance. Do check the detailed blog by David Lutterkort https://thegraph.com/blog/two-simple-subgraph-performance-improvements/
1 reply
0 recast
0 reaction

Shiyas pfp
Shiyas
@shiyasmohd
If you have any more queries, feel free to hop on our discord channel. https://discord.gg/graphprotocol
0 reply
0 recast
0 reaction