Neo4j : Slow Selection Operation with Huge Data

一曲冷凌霜 提交于 2019-12-13 06:46:28

问题


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.


回答1:


  1. run 2 separate statements

  2. 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)



来源:https://stackoverflow.com/questions/42691687/neo4j-slow-selection-operation-with-huge-data

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!