For other readers, see also this other recent thread
A couple of remarks:
- In the separate edge count does it make any difference if you select the edges by label rather than by property, so g.E().hasLabel('Edge2').dedup().count() ? You can see in the JanusGraph data model that the edge label is somewhat easier to access than its properties.
- If you use an indexing backend, it is also possible to do some simple counts against the index, but this will not help you out for your original query.
- You also asked about using Spark. Most of the time, OLAP performance is (still) disappointing. But if you need more details you will have to show what you have tried and what problems you encountered.
Best wishes, Marc