The objective of the query is to find the count of nodes and edges returned. The query is as follows:
g.inject(1).union(V().has('property1', 'A').aggregate('v').outE().has('property1', 'E').aggregate('e').inV().has('property1', 'B').aggregate('v')).select('v').dedup().as('vertexCount').select('e').dedup().as('edgeCount').select('vertexCount','edgeCount').by(unfold().count())
Output: vertexCount: 200k edgeCount: 250k Time took: 1.5 mins
I was trying to optimize the query and tried the following:
g.inject(1).union(V().has('property1', 'A').as('v1').outE().has('property1', 'E').as('e').inV().has('property1', 'B').as('v2')).select('v1','e','v2').by(valueMap().by(unfold())).count()
Output: 250k Time Took: 30 sec It's returning the edge count only.
How can we optimize the query to return both vertex and edge count and also limit on vertex or edge if required??