0
votes

I'm still pretty new to neo4j. I've written a small RESTFUL service which inserts nodes to a neo4j db (server) via REST as a PoC. The structure looks this way: root - [NODES] -> n -> [NODE] -> node

The n node is the one that is "centered". I planned to add other centered node as different node types (e.g. products/categories/documents/attributes/users ...)

In my first example i added approx. 1.000 nodes. Now i tried to increase the aount of nodes and query for that nodes. Now i'm facing a kind of performance "problems". That are my queries, executed at the neo4j (1.6.1) web console

START x = node(0) MATCH PATH = (x - [:NODES] -> centered - [:NODE] -> node) return node ORDER BY node.id LIMIT 10

START x = node(0) MATCH PATH = (x - [:NODES] -> centered - [:NODE] -> node) return count(*)

I need the queries for pagination. The first one should select the elements to be shown and the second one to calculate the pages.

Query times: 1.000 nodes: ~120ms 4.000 nodes: ~200 - 300ms 6.000 nodes: ~250 - 500ms

The cypher query time is increasing very fast (in my opinion). I planned to add ~2.000.000 nodes in that way.Is there anything wrong with my queries? Is it possible to get them faster? (I already setted up my neo4j heap size to 100M, what should be ok for 10k nodes)

Thanks in advance!

2

2 Answers

1
votes

The first thing you can do is to remove the path assignment - you are not using the path PATH, so there's no need to create it.

Other than that, you don't seem to be doing anything wrong here.

Cypher performance for this type of query is much better on 1.7 than 1.6. We released 1.7.M03 yesterday, you can take that out for a spin, if you are not tied down to 1.6.

0
votes

It might help to not have "centered" nodes at all, if they are only descriptors of following node. I think it would be quicker and better organized if you just use index nodes with labels to describe the node types (e.g. products/categories/documents/attributes/users ...). see labels