Re: [Neo4j] Fastest way to count relationships from a particular node.

2011-08-23 Thread Jim Webber
Hey,

What you suggest (a "cache" node") is an OK way of doing things. You could also 
inline the "cached" values in the node itself.

Since managing relationships is atomic with respect to the "cached" counters, 
there will never be inconsistencies.

Jim

___
Neo4j mailing list
User@lists.neo4j.org
https://lists.neo4j.org/mailman/listinfo/user


[Neo4j] Fastest way to count relationships from a particular node.

2011-08-22 Thread noppanit
I've got a little question about what is the fastest way to count
relationships of a node. For example, 

ICE-CREAM
|
| LIKES
|
A -- KNOWS -- B
|
| KNOWS
|
C

If I count it by traversing it would be 2 "KNOWS"s and one LIKE. So, my
question is if I want to count every relationship that comes out of a node a
every time I query something to sort the result by the most relationships
first. So in this example it would be KNOWS first and second LIKES. And it
could be a thousand relationships from node A. I realise that if I count the
relationships every time, the performance would be really bad. 

So, instead of doing that I would have nodes hanging out of Node A and every
time a user inserts a new relationship or an existing node, it would update
those nodes. For example I would have node KNOWS and LIKES hanging out of
Node A and a property count, and the count property will get updated every
time. And those nodes would be indexed as well for fast searching. 

My result is I want to know how many relationships coming out off a
particular node, which categorised by relationship name in almost real time. 

Is this a good approach? 

Thank you very much.

--
View this message in context: 
http://neo4j-community-discussions.438527.n3.nabble.com/Fastest-way-to-count-relationships-from-a-particular-node-tp3276301p3276301.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