The plan changes to one that is far less efficient. It may be a little tough to try to force the planner not to do that.
As an alternate approach, if you have APOC Procedures installed, please try using apoc.path.subgraphNodes()
, as this should be a more efficient approach to matching to distinct nodes when there is a web of paths that can lead to the same nodes.
MATCH (a:Version {version_id: 16674850})
CALL apoc.path.subgraphNodes(a, {relationshipFilter:'DEPENDS_ON>', labelFilter:'>Version', maxLevel:11}) YIELD node as b
RETURN b