Skip to main content

Overview

Graph Node maintains metadata across multiple database tables to track subgraphs, their deployments, and sync state. This metadata is distributed between the primary database and sharded databases to optimize for both consistency and performance.
Most metadata tables are maintained in the primary shard but are periodically copied to other shards to ensure query availability even when the primary is down.

Mapping Subgraph Names to Deployments

subgraphs.subgraph

List of all known subgraph names. Maintained in the primary, with background jobs periodically copying the table to all other shards for query resilience.
The id is used by the hosted explorer to reference the subgraph.

subgraphs.subgraph_version

Mapping of subgraph names to IPFS hashes. Also maintained in the primary with periodic copies to other shards.

Deployment Management

public.deployment_schemas

Directory of all deployments. Maintained in the primary with background job copies to other shards.
There can be multiple copies of the same deployment, but at most one per shard. The active flag indicates which copy will be used for queries. Graph Node ensures exactly one active copy exists for each IPFS hash.

subgraphs.head

Details about a deployment that change on every block. Maintained in the shard alongside the deployment’s data in sgdNNN.
The head block pointer (block_number and block_hash) represents the latest fully processed block. It remains null until the deployment processes its first block. For grafted or copied deployments, the head stays null until the graft/copy completes, which can take considerable time.

subgraphs.deployment

Tracks sync progress and deployment details. Maintained in the shard alongside the deployment’s data.
The reorg-related columns (reorg_count, current_reorg_depth, max_reorg_depth) are set during indexing to determine whether a reorg happened during query execution and if it could have affected the query results.

subgraphs.subgraph_manifest

Stores deployment details that rarely change. Maintained in the shard alongside deployment data.

Additional Metadata Tables

subgraphs.subgraph_deployment_assignment

Tracks which index node is indexing each deployment. Maintained in the primary with periodic copies to other shards.
This table could simply be a column on deployment_schemas.

subgraphs.dynamic_ethereum_contract_data_source

Stores dynamic data sources for all subgraphs.
This table will soon be moved into each subgraph’s namespace (sgdNNN).

subgraphs.subgraph_error

Stores details about errors encountered during indexing.

Deployment Copying

The following tables track deployment copying progress:
  • active_copies (in primary)
  • subgraphs.copy_state
  • subgraphs.copy_table_state
These ensure copying works correctly across index node restarts.

subgraphs.table_stats

Stores information about which tables should have the ‘account-like’ optimization enabled for query generation.

subgraphs.subgraph_features

Details about features used by deployments. Maintained in the primary.

Metadata Distribution Strategy

This distribution strategy ensures that:
  1. Critical routing information is available on all shards
  2. Queries can be served even when the primary shard is unavailable
  3. Frequently changing data stays close to the deployment data
  4. Background jobs keep replicated data synchronized