graphman.
Prerequisites
The Ensure you have a configuration file set up. See the basic setup guide if you need to create one.
graphman command is included in official Graph Node containers. You can access it via:Logging Configuration
Graphman respects theGRAPH_LOG environment variable. To reduce log noise:
Verify Setup
Confirm graphman is configured correctly:Removing Unused Deployments
When you deploy a new version of a subgraph, the previous version’s data remains in the database even after it’s no longer served for queries. These unused deployments consume storage and should be periodically cleaned up.Understanding Unused Deployments
A deployment is considered unused when it meets all of these criteria:- Not assigned to any node
- Either not marked as active, or is neither the current nor pending version of a subgraph
- Not the source of a currently running copy operation
Cleanup Process
Record unused deployments
Scan all shards and identify unused deployments:This compiles a list and stores it in the
unused_deployments table in the primary shard.No data is deleted at this stage. This command only identifies and marks deployments for removal.
Review the list
Inspect which deployments are marked for removal:Verify that the listed deployments should indeed be removed.
Removal Options
Theunused remove command supports several options for fine-grained control:
Remove all unused deployments
Remove all unused deployments
unused record.Remove deployments older than a specific time
Remove deployments older than a specific time
Remove a specific deployment
Remove a specific deployment
Limit the number of removals
Limit the number of removals
Removing a Subgraph
To stop serving a specific subgraph and free its name for reuse:Remove the subgraph name mapping
Removing a subgraph name does not immediately delete indexed data. The deployment becomes eligible for cleanup through the unused deployment process.
Modifying Assignments
Each deployment is assigned to a specific Graph Node instance for indexing. You can modify these assignments to control which node indexes which subgraphs.Reassigning Deployments
Move a deployment to a different node:<deployment>- The deployment identifier (name, IPFS hash, or namespace)<new-node-id>- The target node ID from your Graph Node configuration
- Load balancing across multiple nodes
- Moving deployments off a node before maintenance
- Isolating problematic subgraphs
Unassigning Deployments
Permanently stop indexing a deployment:To resume indexing, reassign the deployment to an active node. No data is lost during unassignment.
Pausing Indexing
To temporarily pause a deployment without losing its assignment:Complete Deployment Removal
To fully remove a deployment in a single operation:Drop Command Options
Drop by subgraph name
Drop by subgraph name
Drop by IPFS hash
Drop by IPFS hash
Drop only current versions
Drop only current versions
Drop only pending versions
Drop only pending versions
Skip confirmation prompt
Skip confirmation prompt
Maintenance Workflows
Regular Cleanup Schedule
Establish a routine maintenance schedule:Weekly: Review and remove
Wait 24-48 hours, then:This ensures deployments have been truly unused for at least a day.
Pre-Deployment Cleanup
Before deploying a new version:Node Maintenance
When performing maintenance on a Graph Node instance:Best Practices
Verify before deleting
Verify before deleting
Always use
graphman info and unused list to confirm which deployments will be affected before running destructive operations.Use time buffers
Use time buffers
Wait at least 1 hour (preferably 24 hours) between marking deployments as unused and removing them using the
--older flag.Monitor disk usage
Monitor disk usage
Track database size trends to determine optimal cleanup frequency. Unused deployments can consume significant storage.
Document assignments
Document assignments
Maintain a record of which deployments are assigned to which nodes, especially in multi-node setups.
Test in staging
Test in staging
If possible, test maintenance operations in a staging environment before running them in production.
Automate routine tasks
Automate routine tasks
Create scripts for regular maintenance tasks, but always include safety checks and confirmation steps.
Keep deployment history
Keep deployment history
Before removing old deployments, consider exporting critical data or keeping deployment metadata for audit purposes.
Troubleshooting Common Issues
Deployment won’t unassign
Symptom: Unassign command fails or deployment continues indexing. Solutions:- Verify the deployment identifier is correct
- Check that no queries are actively using the deployment
- Ensure the node is not restarting or in an error state
Unused remove doesn’t delete deployment
Symptom: Deployment remains in database afterunused remove.
Causes and solutions:
- Not marked as unused: Run
graphman unused recordfirst - Still assigned: Unassign the deployment before marking as unused
- Recent deployment: Use
--older 0to remove immediately (not recommended) - Active queries: Wait for queries to complete
Can’t reassign deployment
Symptom: Reassign command fails or assignment doesn’t change. Solutions:- Verify the target node ID exists in your configuration
- Check that the target node is running and connected to the database
- Ensure the deployment isn’t in a failed state
- Try unassigning first, then creating a new assignment
Database space not freed after removal
Symptom: Disk usage remains high after removing deployments. Solutions:- Run PostgreSQL’s
VACUUM FULLon affected schemas (requires downtime) - Consider using
VACUUMregularly to mark space as reusable - Check for other large tables or indexes
- Monitor the primary shard’s
unused_deploymentstable size
Automation Examples
Daily Cleanup Script
Deployment Migration Script
Additional Resources
- Graphman CLI Reference - Complete command documentation
- Configuration File Guide - Setup and configuration
- Monitoring Guide - Track deployment health and performance
- Pruning Guide - Optimize storage with data pruning

