Thank you for the suggestions!

I have an unique constraint on Post(id):

CREATE CONSTRAINT ON (p:Post) ASSERT p.id IS UNIQUE;


NODE_GLOBAL and breadthFirst() didn't make it any faster.
The properties on post are id and title (empty string).

Returning count(node) made it much faster and is in the range of 50-100ms.

What I noticed is that even simple queries take around 10ms. That also 
seems very long:

(This is running on Neo4j 3.1.1 with 2G Heap)

neo4j-sh (?)$ return 5;
+---+
| 5 |
+---+
| 5 |
+---+
1 row
9 ms
neo4j-sh (?)$ match (n:Post {id:"3235"}) return n;
+-----------------------+
| n                     |
+-----------------------+
| Node[3234]{id:"3235"} |
+-----------------------+
1 row
8 ms
neo4j-sh (?)$ match (n:Post {id: "3235"}) CALL connectedComponent(n) yield 
node return count(node);
+-------------+
| count(node) |
+-------------+
| 15762       |
+-------------+
1 row
77 ms
neo4j-sh (?)$

The current traversal implementation:
        return graphDatabaseService.traversalDescription()
               .breadthFirst()
               .relationships( RelTypes.CONNECTS, Direction.OUTGOING )
               .uniqueness( Uniqueness.NODE_GLOBAL )
               .traverse( start )
               .nodes().stream().map(Visited::new);



Mattias, which kind of profiling do you mean? JVM?


Am Montag, 23. Januar 2017 08:53:49 UTC+1 schrieb Mattias Persson:
>
> Max, `.nodes()` does this, gets the `endNode()` of all paths.
>
> Felix, that sounds awfully long, have you run some profiling on this?
>
> On Friday, January 20, 2017 at 7:28:35 PM UTC+1, Felix Dietze wrote:
>>
>> Hi,
>>
>> I'd like to know if its possible to do a faster traversal than in this 
>> stored procedure.
>>
>> I want to return all reachable (directed) nodes from a startnode:
>>
>> public class ConnectedComponent {
>>     @Context
>>     public GraphDatabaseService graphDatabaseService;
>>
>>
>>     private static enum RelTypes implements RelationshipType {
>>         CONNECTS
>>     }
>>
>>
>>     @Procedure(value = "connectedComponent")
>>     public Stream<Visited> connectedComponent(@Name("start") Node start) 
>> {
>>         return graphDatabaseService.traversalDescription()
>>                .depthFirst()
>>                .relationships( RelTypes.CONNECTS, Direction.OUTGOING )
>>                .uniqueness( Uniqueness.RELATIONSHIP_GLOBAL )
>>                .traverse( start )
>>                .nodes().stream().map(Visited::new);
>>     }
>>
>>
>>     public static class Visited {
>>         public final Node node;
>>         public Visited(Node node) {
>>             this.node = node;
>>         }
>>     }
>> }
>>
>>
>> I call the procedure like this:
>> match (n:Post {id: "3235"}) CALL connectedComponent(n) yield node return 
>> node;
>>
>>
>> This takes around 3 seconds for 15k visited nodes. That's about 10x slower 
>> compared to a stored procedure in postgres on the same data. Any ideas?
>>
>>
>>
>> Thank you!
>>
>>

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to