Search code examples
orientdborientdb2.2

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.


Solution

  • Try this:

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

    Hope it helps

    Regards