Re: The count query based on the vertex traversal edges is too slow!!!

wd w <wangwe...@...>

Thank you very much for your answersWhen I change the query statement to look like yours , it can go index query normally!

g.V().hasLabel('InstanceMetric').has('type', neq('network)).has('vlabel', 'InstanceMetric')
    .inE('Cause').has('status', -1).has('isManual', false)
        .has('promote', within(-1,0,2,3)).has('vlabel', 'Cause')
        .where(outV(). .hasLabel('InstanceMetric').has('type', neq('network)).has('vlabel', 'InstanceMetric') ).range(0,10)

But I found another problem, when the data ragne is 0~10, it takes less than 400ms to execute, when the data range is 30000~300010, it takes more than 12s+ to execute,  Does it start reading from 0 to 300000 and then read the data from 300000 to 300010?

The vertex number of 'InstanceMetric' just is 344. 
The edge number of 'Cause' is 300000+ and there are 300,000 edges established between two vertices

在2020年10月25日星期日 UTC+8 下午11:57:58<HadoopMarc> 写道:


Apparently, the query planner is not able to use the index for the outV() step. Can you see what happens if we split the query like this (not tested):

targetIds = g.V().hasLabel('InstanceMetric').has('type', neq('network)).has('vlabel', 'InstanceMetric').toList()

g.V().hasLabel('InstanceMetric').has('type', neq('network)).has('vlabel', 'InstanceMetric')
    .inE('Cause').has('status', -1).has('isManual', false)
        .has('promote', within(-1,0,2,3)).has('vlabel', 'Cause')
        .where(outV().has(id, within(targetIds)))

Note that you can use the where() step instead of the as/select construct, just for readability.

HTH,   Marc

Op zaterdag 24 oktober 2020 om 15:19:12 UTC+2 schreef wan...@...:
The total number of sides is 15000

The edge data meets the query condition is only 10000 in total

在2020年10月24日星期六 UTC+8 下午9:18:48<wd w> 写道:

在2020年10月20日星期二 UTC+8 下午10:38:46<HadoopMarc> 写道:
Can you show the profiling of the query using the profile() step?

Best wishes,    Marc

Op dinsdag 20 oktober 2020 om 14:22:59 UTC+2 schreef wan...@...:

g.V().hasLabel("Instance").has("instanceId", P.within("12", "34")).bothE('Cause').has('enabled', true).as('e').bothV().has('instanceId', P.within('64', '123')).select('e').count();

The above count query executes very slowly, what method can be used to speed up its query.

I have created compositeIndex and  mixedIndex for instanceId, enabled.

How should I convert this query to a direct index query!

Join to automatically receive all group messages.