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.
ColumnTypeUse
idtext!primary key, UUID
nametext!user-chosen name
current_versiontextsubgraph_version.id for current version
pending_versiontextsubgraph_version.id for pending version
created_atnumeric!UNIX timestamp
vidint8!unused
block_rangeint4range!unused
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.
ColumnTypeUse
idtext!primary key, UUID
subgraphtext!subgraph.id
deploymenttext!IPFS hash of deployment
created_atnumericUNIX timestamp
vidint8!unused
block_rangeint4range!unused

Deployment Management

public.deployment_schemas

Directory of all deployments. Maintained in the primary with background job copies to other shards.
ColumnTypeUse
idint4!primary key
subgraphtext!IPFS hash of deployment
nametext!name of sgdNNN schema
versionint4!version of data layout in sgdNNN
shardtext!database shard holding data
networktext!network/chain used
activeboolean!whether to query this copy of the deployment
created_attimestamptz!
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.
ColumnTypeUse
idinteger!primary key, same as deployment_schemas.id
block_hashbyteacurrent subgraph head
block_numbernumeric
entity_countnumeric!total number of entities
firehose_cursortext
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.
ColumnTypeUse
idinteger!primary key, same as deployment_schemas.id
subgraphtext!IPFS hash
earliest_block_numberinteger!earliest block for which we have data
healthhealth!
failedboolean!
fatal_errortext
non_fatal_errorstext[]
graft_basetextIPFS hash of graft base
graft_block_hashbyteagraft block
graft_block_numbernumeric
reorg_countinteger!
current_reorg_depthinteger!
max_reorg_depthinteger!
last_healthy_ethereum_block_hashbytea
last_healthy_ethereum_block_numbernumeric
debug_forktext
synced_attimestamptztime when deployment first reach chain head
synced_at_block_numberintegerblock number where deployment first reach chain head
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.
ColumnTypeUse
idinteger!primary key, same as deployment_schemas.id
spec_versiontext!
descriptiontext
repositorytext
schematext!GraphQL schema
featurestext[]!
graph_node_version_idinteger
use_bytea_prefixboolean!
start_block_hashbyteaParent of the smallest start block from the manifest
start_block_numberint4
on_synctextAdditional behavior when deployment becomes synced
history_blocksint4!How many blocks of history to keep

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.
ColumnTypeUse
idint4!primary key, ref to deployment_schemas.id
node_idtext!name of index node
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.
ColumnTypeUse
idtext!primary key
spec_versiontext!
api_versiontext
featurestext[]!
data_sourcestext[]!
handlerstext[]!

Metadata Distribution Strategy

- subgraphs.subgraph
- subgraphs.subgraph_version
- public.deployment_schemas
- subgraphs.subgraph_deployment_assignment
- subgraphs.subgraph_features
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

Build docs developers (and LLMs) love