Course contentsShow
← System Design
Lesson 478 of 1,91913. NoSQL: Graph DatabasesFree lesson

When Graphs Underperform: Aggregations and Scans

Recognizing workloads where relational or analytical databases outperform graphs: aggregations and full scans.

When Graphs Underperform: Aggregations and Scans

What you'll learn: You'll understand when graph databases struggle and relational or analytical databases shine instead.

The Graph's Weakness

Graph databases excel at traversing relationships—finding friends of friends, shortest paths, or complex patterns. But they're not optimized for every workload. When you need to aggregate data across all nodes or scan large portions of your graph without following specific relationship paths, graphs often underperform compared to relational or analytical databases.

Where Graphs Struggle

Full table scans are a graph database's Achilles heel. Imagine you need to calculate the average age of all users in your social network, or count how many products were sold across all categories. These operations don't leverage the graph's strength—index-free adjacency—because you're not traversing relationships. You're just reading every node.

Think of it like this: a graph database is a map with perfect directions between specific locations. It's fantastic for "how do I get from A to B?" But if you need to count every tree in the entire country? You'd be better off with satellite imagery (an analytical database) that's designed to scan large areas efficiently.

Aggregation queries also suffer. Summing revenue, calculating averages, or grouping by attributes across millions of nodes means the graph database must touch vast amounts of data without using its relationship-based indexes. Relational databases with columnar storage or dedicated analytical databases (like data warehouses) handle these workloads far more efficiently.

The Right Tool for the Job

If your queries are primarily "find all X" or "sum/average/count across Y," you likely don't need a graph database. You need something optimized for batch processing and analytics.

Key Takeaway: Graph databases underperform on aggregations and full scans because these operations don't leverage relationship traversal—use relational or analytical databases for workloads dominated by these patterns.