Michael
Michael

Reputation: 715

Efficient (graph) aggregations in OrientDB

Given a graph with interconnected entities:

enter image description here

What is the most efficient way to aggregate common Vertices based on Edges. For instance - with the given graph - return Musicians with an aggregated band count.

My current approach is aggregating post selection:

select m, count(b) as cnt from (match {class:Musician, as: m}<-currentMember-{as:b} return m, b) group by m order by cnt desc limit 10

But this looks highly inefficient.

Upvotes: 0

Views: 73

Answers (1)

Michela Bonizzi
Michela Bonizzi

Reputation: 2632

Try this:

select name, in('currentMember').size() as band from Musician order by band desc

Hope it helps

Regards

Upvotes: 2

Related Questions