Steven, in this scenario, you are reading up the entire db, and basically have it cold. Neo4j is not optimized in itself to do full graph-scans. I see a few solutions for you:
- store the number of relationships as a property on nodes and read only that. this works if the updates to your graph are not too frequent. - Store the relationships as a property in an Index (e.g. Lucene) and as the index for all entries. Thus, you are using an index for what it is good at - global operations over all documents. - use HA or just file copy to replicate the graph on several instances, and send a sharded query to all of them (e.g. count 100K node degrees on all of the instances and return the result). This query is very easy to do in a map/reduce fashion. Is that feasible? Cheers, /peter neubauer GTalk: neubauer.peter Skype peter.neubauer Phone +46 704 106975 LinkedIn http://www.linkedin.com/in/neubauer Twitter http://twitter.com/peterneubauer http://www.neo4j.org - Your high performance graph database. http://startupbootcamp.org/ - Öresund - Innovation happens HERE. http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing party. On Tue, Sep 20, 2011 at 1:00 PM, st3ven <st3...@web.de> wrote: > Peter, > > the import of the data into the graph database is not the main problem for > me. > The lookup of nodes from the index is fast enough for me. > To create the database it took me nearly half a day. > > My main problem here is getting the node degree of every node. > As I already said I am using this code to get the node degree of every node: > > for (Node node : db.getAllNodes()) { > counter = 0; > > if (node.getId() > 0) { > for (Relationship rel : > node.getRelationships()) { > counter++; > } > > System.out.println(node.getProperty("name").toString() + ": " > + counter); > } > > } > > After 3 days I only got the node degree of 80000 nodes and I want to > optimize my traversal here, cause this is very slow. > What can I do to make this faster or do I have to change my code for getting > the node degree? > I only posted my import code because I thought I could maybe optimize there > something for this traversal. > > Thank you very much for your help! > > Cheers, > Stephan > > > -- > View this message in context: > http://neo4j-community-discussions.438527.n3.nabble.com/Creating-a-graph-database-with-BatchInserter-and-getting-the-node-degree-of-every-node-tp3351599p3351664.html > Sent from the Neo4j Community Discussions mailing list archive at Nabble.com. > _______________________________________________ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > _______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user