Back to Common Questions

Common Questions / Choosing an approach

How much faster is Substreams than a subgraph?

Updated

For a historical backfill, a lot faster. In a benchmark run by The Graph's BuildersDAO, indexing Uniswap V4 on Ethereum took 23 hours as a subgraph and 7 minutes 36 seconds on Substreams — 182x faster. On Base it took 94 hours 19 minutes versus 2 hours 6 minutes, 45x faster.

The reason is structural: a subgraph processes history one block after another, while Substreams splits history into segments and processes them in parallel. See why is my subgraph syncing so slow?.

What exactly was measured?

BuildersDAO ran a like-for-like comparison: the same Uniswap V4 events, the same Postgres database, and the same block ranges.

NetworkBlock rangeSubgraphSubstreams (75 workers)Speedup
Ethereum21,688,328 – 23,535,547 (about 1.8M blocks)23h 00m7m 36s182x
Base25,350,987 – 36,712,209 (about 11.4M blocks)94h 19m2h 06m45x

Substreams ran on a cold cache using Substreams v1.22.0, writing into Postgres 16 with the built-in substreams sink postgres. The environment was Ubuntu 24.04 with a 1.8 TB disk, using the Uniswap V4 events package and StreamingFast endpoints.

Does adding workers make it faster still?

Up to a point. Parallelism is set with the X-Substreams-Parallel-Workers header:

WorkersEthereumBase
18h 12m28h 41m
51h 37m26h 51m
1536m9h 10m
757m 36s2h 06m
3007m 30s56m 38s

Ethereum's gains flatten around 75 workers; Base has far more data, so it keeps gaining out to 300. At 300 workers throughput reached about 4,100 blocks per second on Ethereum and 3,300 on Base, end to end into Postgres. See how to speed up a Substreams backfill.

What made the sink faster?

Three changes to the SQL sink account for most of the improvement: a disk spool so a slow database does not stall the stream, Postgres constraints deferred until the sink reaches chain head, and a faster protobuf unmarshaller.

Will I see the same numbers?

Not necessarily. These figures are for one workload (Uniswap V4 events), on cold-cache runs with a Pro Plan subscription, and the speedup depends on the chain, the module, and your database. The longer the backfill, the more extra workers help.


Frequently asked questions

Does this apply to live data too? No. Live indexing is bounded by block time for both approaches. The difference is in historical backfills and in how quickly you can reprocess after changing your logic.

Do I have to rewrite my subgraph to get this? You rebuild the extraction layer as a Substreams package; the agent skills can do most of the port. See how to migrate from a subgraph to Substreams.


Get an API key at thegraph.market.

Related: Why is my subgraph syncing so slow? · How do I backfill historical blockchain data? · Subgraph vs API — which should you use?