diff --git a/.changesets/fix_sachin_avoid_precomputing_non_trivial_followup_edges_for_subgraph_query_graphs.md b/.changesets/fix_sachin_avoid_precomputing_non_trivial_followup_edges_for_subgraph_query_graphs.md new file mode 100644 index 0000000000..016fc65238 --- /dev/null +++ b/.changesets/fix_sachin_avoid_precomputing_non_trivial_followup_edges_for_subgraph_query_graphs.md @@ -0,0 +1,5 @@ +### Avoid unnecessary precomputation during query planner construction ([PR #8373](https://github.com/apollographql/router/pull/8373)) + +A regression introduced in v2.5.0 caused query planner construction to unnecessarily precompute metadata, which can lead to increased CPU and memory utilization during supergraph loading. Query planner construction now correctly avoids this unnecessary precomputation. + +By [@sachindshinde](https://github.com/sachindshinde) in https://github.com/apollographql/router/pull/8373 \ No newline at end of file diff --git a/apollo-federation/src/query_graph/build_query_graph.rs b/apollo-federation/src/query_graph/build_query_graph.rs index bb142fb0f7..d8285fc43f 100644 --- a/apollo-federation/src/query_graph/build_query_graph.rs +++ b/apollo-federation/src/query_graph/build_query_graph.rs @@ -427,8 +427,12 @@ impl SchemaQueryGraphBuilder { if self.for_query_planning { self.add_additional_abstract_type_edges()?; } - // This method adds no nodes/edges, but just precomputes followup edge information. - self.base.precompute_non_trivial_followup_edges()?; + // This method adds no nodes/edges, but just precomputes followup edge information. We don't + // need this when building subgraph query graphs (since federated query graph building takes + // care of it), so we accordingly skip precomputation in that case. + if self.subgraph.is_none() { + self.base.precompute_non_trivial_followup_edges()?; + } Ok(self.base.build()) }