# Performance Considerations

When dealing with large datasets (millions of nodes/edges), optimization becomes critical.

# Batching

Curiosity's graph.CommitPendingAsync() automatically handles batching, but you can control the frequency of commits to balance memory usage and speed.

# Parallel Ingestion

If your data source allows, you can run multiple ingestion tasks in parallel. However, be mindful of potential write conflicts if multiple tasks attempt to update the same nodes or edges simultaneously.

# Efficient Lookups

When linking nodes, use Node.Key(type, key) instead of fetching the full node object first. This avoids unnecessary database reads.

// FAST: Only uses the key to create the link
graph.Link(partNode, Node.Key(nameof(Nodes.Device), deviceName), Edges.PartOf);

# Memory Management

For extremely large JSON files, avoid deserializing everything into memory at once. Use a streaming JSON reader (like Utf8JsonReader) to process items one by one.