Reputation: 2611
I am trying to the nodes from the Graph randomly each time. the number of nodes is 24600968 in the database. The following query
MATCH (n:Employee)
WITH n AS emp,rand() AS ids ORDER BY ids LIMIT 10
MATCH (n:Company)
WITH emp, n AS com,rand() AS ids ORDER BY ids LIMIT 10
RETURN emp.guid,com.guid
is taking very long time. The time is
Returned 10 rows in 306863 ms.
How can I speed up this process.
Upvotes: 0
Views: 121
Reputation: 41686
run 2 separate statements
try this
Lookup nodes by a random set of ids and check if they are an employee
MATCH (n) WITH count(*) as total
WITH [_ IN range(1,10000) | toInt(rand()*total)] as ids
MATCH (emp) WHERE id(emp) IN ids AND emp:Employee
RETURN emp LIMIT 10
Your query generates a list of 24M random values and sorts it (twice) while also pulling that many nodes from the graph into memory (not sure how much memory you have)
Upvotes: 2