Your main problem is, in fact, memory when you try to load all paths. If this is the statistics you want, you will almost certainly be better off with the Traverser API so you can control the load / aggregation of nodes.
If you want to stick with Cypher, this can help split each sector into its own request so that they can work better in parallel. If you have full control over reading / writing the database, then another option is to create initial nodes that you can update when reading / writing. Thus, you do not need to know all the ways how this change affects statistics. You can also create direct relationships from the sector to interesting sites and simply collect the necessary information into one element, for example
(sector)-[:HAS_CAT]->(cat) WITH sector, collect(cat.name) as Categories
Thus, with each match, you can consolidate back to the original number of columns.
Tezra
source share