How Jredisgraph is slower

Hello Team,
I’ve one million record In my redisgraph and also I created relationship for that 1 million nodes.

I created the configuration like below In Java (ec2 instance )

@Bean
public RedisGraphAPI redisGraphApi() {
JedisPool pool = new JedisPool(new JedisPoolConfig(), “ec2”, 63797, Protocol.DEFAULT_TIMEOUT, “mypass”);
return new RedisGraphAPI(graphId, pool);
}

I started querying that 1 million nodes from java application and capturing the metrics.

I got exception socket timeout
So I changed Protocol.DEFAULT_TIMEOUT manually as 100000
I’m just querying 1millon node id by below query

Match (n:user),(m:user) n.user-[:friend]->m.user where n.userid= 123 return m.user.id

My results are matching, only issue is duration.

I compared the duration with neo4j.

While comparing with neo4j, neo4j results are faster than redisgraph.

Can anyone tell me what might go wrong in it.

Thanks in advance

Hi, what is the default timeout ?
Can you please share the execution plan for this query?

Is the query latency consistent, e.g. running the same query multiple times yields the same query execution time?

The Protocol.DEFAULT_TIMEOUT is 2000

public List getUpline(Long id) {
Long startTime = System.nanoTime();
Resultset resut=graph.query(“User”,MATCH (n:User)-[:Friends*]->(m:User)WHERE m.id=" + id + " RETURN n.id);
Long endTime = System.nanoTime();
Long duration = (endTime - startTime)/ 1000000L;
System.out.println("Duration in Nano: "+(endTime-startTime));
System.out.println("Duration in Micro: "+duration);
List objectList = new ArrayList<>();
while (resultSet.hasNext()) {
Record record = resultSet.next();
objectList.add(record.values());
}
return objectList;
}
This the actual implementation in my java application.

querying only once to retrieve all the user id from that 1 million record and capturing the query duration.
Correct me if i’m wrong

2000 milliseconds I guess,
Your query is quite expensive as it might traverse through the entire graph, this is the execution-plan:

1) "Results"
2) "    Project"
3) "        Conditional Traverse | (n:User)->(n:User)"
4) "            Conditional Variable Length Traverse | (m:User)<-[anon_0:Friends*1..INF]-(n:User)"
5) "                Filter"
6) "                    Node By Label Scan | (m:User)"

By specifying the relation: -[:Friends*]-> you’re performing a none capped traversal,
Consider a graph with 10 nodes where each node K is connected to node K+1.
if m in your query is node 10 then the traversal would visit nodes 9 through 1.

I can easily see how this can spin out of control with other graph structures.

1 Like

Thank you Very much SWilly,

Can you give me an idea, how i can query it in a efficient manner.

What is it exactly that you’re trying to do?