Michael,
for your query you should use a Label besides your name property.
And then there should be an index like: create index on :Label(name);
You should use parameters in your query like MATCH (a:Label {name: {name}})
Currently for variable length limits there is no parameter allowed, so your
substitution is ok, what are the values for the "range" ?
If your model contains two directional relationships of the same type
between two nodes (i.e. two of opposite direction between two nodes then
you might consider removing one of them)
You already ignore direction in your query. Otherwise the query turns in
tiny circles all the time.
For longer paths, please take into account that the number of paths grows
exponentially with the number of rels. ( number_of_rels ^ steps ).
So you could have cypher "RETURN distinct x"
The existing query planner in cypher is not able to discern unique results
in terms of minimizing path cardinalities in between, the new planner, that
you can enable with a prefix "cypher 2.1.experimental " should do a better
job there.
For the old planner, what I usually do is to use WITH in between after the
path length 3 to minimize the cardinality again to reduce the number of
paths matched.
e.g.
MATCH (a:Label {name: {name}})-[:TYPE]->(l1)-[:TYPE]->(l2)
WITH distinct l2
MATCH (l2)-[:TYPE]->(l3)
RETURN distinct l3
Also if your "name" property is an integer? Something might be wrong?
Michael
On Sun, Nov 9, 2014 at 11:13 PM, Michael Shapiro <[email protected]>
wrote:
> I have built a DB using this batch script
> <http://jexp.de/blog/2014/10/flexible-neo4j-batch-import-with-groovy/>
> My DB contains about 53 millions node and about 90 millions relationships.
> I want to perform a query to find all the neighbors of a certain node. So
> I'm using the following query (connect to the DB engine with JAVA):
>
> String query = String.format("MATCH (a { name: '%s' }) -[*0..%d]-(x)
> RETURN x", nodeName, range);
>
>
> The query completes very fast, but when I try to read the result using
> the "*IteratorUtil*" class, whatever function I call
> (count, asIterable, first..) the program stops responding.
>
> I'm using the following configuration for the JVM:
>
> *-Xms512m*
> *-Xmx2g*
> *-XX:-UseGCOverheadLimit*
> *-XX:MaxPermSize=512m*
> *-XX:+UseConcMarkSweepGC *
>
>
> My code:
>
> Transaction tx = mGraphDB.beginTx();
> try
> {
> String query = String.format("MATCH (a { name: '%s' }) -[*0..%d]-(x)
> RETURN x", nodeName, range);
> result = mDBEngine.execute( query );
> Iterator<Node> n_column = result.columnAs( "x" ); for ( Node node :
> IteratorUtil.asIterable( n_column ) )
> {
> res.nodesIDList.add(i, (Integer)node.getProperty(name));
> }
> tx.success();
> ...
> }
> catch (Exception e)
> {
> tx.failure();
> ...
> }
> finally
> {
> tx.close();
> }
>
>
> Any idea on how to fix this?
>
> --
> 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.
>
--
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.