org.neo4j.gis.spatial.SimplePointLayer.findClosestPointsTo(Coordinate, double) very low performance

73 views
Skip to first unread message

Antonio Grimaldi

unread,
Apr 16, 2014, 11:59:38 AM4/16/14
to ne...@googlegroups.com
Hi,
We are using Neo4J 2.0 embedded and have a Graph with around 1 Million of Nodes, and 50 Million of relationships; 
When call org.neo4j.gis.spatial.SimplePointLayer.findClosestPointsTo(Coordinate, double), to get all closest node from a given point, we have very low performance.
Is there a reason for this? or is there any other faster way?

Thanks
Antonio

Michael Hunger

unread,
Apr 16, 2014, 3:43:26 PM4/16/14
to ne...@googlegroups.com
Can you share more details (code) about what you're doing there? And where you see that peformance drop and your deployment mode and neo4j version?

Thanks

--
You received this message because you are subscribed to the Google Groups "Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email to neo4j+un...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Antonio Grimaldi

unread,
Apr 17, 2014, 4:46:04 AM4/17/14
to ne...@googlegroups.com
Hi Michael, thanks for the answer.

I'm using neo4j 2.0, neo4j spatial 0.12-neo4j-2.0.0  and neo4j.graph.collections 0.7.1-neo4j-2.0.0 in order to build a route system.

I'ld like to create my own graph model; in my graph model I'ld like to:

  • create nodes and index them by using the spatial index in this way :

GraphDatabaseBuilder gdbb = gdbf.newEmbeddedDatabaseBuilder(neo4jDbPath);
gdbb.setConfig......

Label mainNodeLabel = DynamicLabel.label("nodoPrincipale");

GraphDatabaseService graphDb = gdbb.newGraphDatabase();
SpatialDatabaseService sdb = new SpatialDatabaseService(graphDb);
SimplePointLayer mainPointsLayer = sdb.createSimplePointLayer("mainPointsLayer", "x", "y");

Schema dbSchema = graphDb.schema();
dbSchema.indexFor(mainNodeLabel).on("x").create();
dbSchema.indexFor(mainNodeLabel).on("y").create();
dbSchema.indexFor(mainNodeLabel).on("giunzioneDbId").create();

org.neo4j.graphdb.Node graphNode = graphDb.createNode(mainNodeLabel);
graphNode.setProperty("y", y);
graphNode.setProperty("x", x);
 
mainPointsLayer.add(graphNode);
tx.success();


  • create relationships between created nodes :

Relationship rs = startGraphNode.createRelationshipTo(endGraphNode, relationType);


  • get all closest node from a given point :

StopWatch sw = new StopWatch();
sw.start("findClosestPointsTo");
// Check whether we can find a node from which is located within a 
distance of 250 meters
List<GeoPipeFlow> results = el.findClosestPointsTo(coord, 0.25);
sw.stop();
if (logger.isInfoEnabled()) {

logger.info("findClosestPointsTo run in " + sw.getLastTaskTimeMillis() + " millis.");
}

with this log info : 
  1. "findClosestPointsTo run in 27626 millis" (for the firts time)
  2.  "findClosestPointsTo run in 2712 millis" (for the second time)
  3. "findClosestPointsTo run in 148 millis" (for the third time, after 15 minutes from the second time)
  4. "findClosestPointsTo run in 698 millis" (for the quarte time, after 15 minutes from the second time).
with my intel core I7 machine with 4GB ram.

Thanks Antonio

Angelo Immediata

unread,
Apr 17, 2014, 11:29:23 AM4/17/14
to ne...@googlegroups.com
Hi there...any tips on this issue? 
I'm having the same problem in my own scenario. 

Thank you
Angelo


Il giorno mercoledì 16 aprile 2014 17:59:38 UTC+2, Antonio Grimaldi ha scritto:

Antonio Grimaldi

unread,
Apr 22, 2014, 5:38:42 AM4/22/14
to ne...@googlegroups.com
Hi there, 

No one can help me?


thanks

Michael Hunger

unread,
Apr 22, 2014, 8:34:38 AM4/22/14
to ne...@googlegroups.com
Hi Antonio & Angelo,

how many geo-nodes do you have in total of that 1M?

How many nodes are returned from that search?

What OS do you have, what neo4j config?


On an unrelated note - you don't need the schema index for this.


--

Antonio Grimaldi

unread,
Apr 23, 2014, 5:37:59 AM4/23/14
to ne...@googlegroups.com
Hi Michael,
We try to answer to your question : 

In our graph we have only geo-nodes (we are create a routing machine so we read the osm file and create nodes in neo4j);

Generally findClosestPointsTo method returns a range of nodes number between 10 and 150. 
We saw that the first time we call the method it takes a long time to be executed (min 30s - max 180s). 
On the next calls the method is faster (min 148 millis - max 650 millis), but after sometimes it became again slow.

We tested it windows 7 and ubuntu 12.04.04 both of them 64 bit

This is neo4j configuration : 

nodestore_mapped_memory_size=100M
relationshipstore_mapped_memory_size=3G
nodestore_propertystore_mapped_memory_size=100M
strings_mapped_memory_size=200M
arrays_mapped_memory_size=50M
keep_logical_logs=true

ps. we need the schema index because we need to o same chyper query on same node propertis (like x, y, and giunzioneDbId)
 
Thank you,
Angelo & Antonio

 

Il giorno mercoledì 16 aprile 2014 17:59:38 UTC+2, Antonio Grimaldi ha scritto:

Angelo Immediata

unread,
Apr 28, 2014, 4:32:01 AM4/28/14
to ne...@googlegroups.com
Hi Michael

do you have any suggestion about this?

Thank you
Angelo


Il giorno mercoledì 16 aprile 2014 17:59:38 UTC+2, Antonio Grimaldi ha scritto:
Reply all
Reply to author
Forward
0 new messages