My database has the following "schema":
- users author posts
- users like posts
My modest test database contains:
- 162 users
- 442 posts
- 159 likes
Now I would like to query the most popular users, which is the users who have gathered the most likes across all their posts. I came up with the following query:
FOR u IN users
LET nblikes = SUM(FOR post IN 1 OUTBOUND u isAuthor
RETURN LENGTH(GRAPH_EDGES('my-graph', post, { edgeCollectionRestriction: 'likes' })))
SORT nblikes DESC
RETURN {
"username": u.username,
"nblikes": nblikes
}
which executes in approximately 0.8s on my Mid-2014 MacBookPro (2.8GHz Core i7, 16GB RAM). 0.8s isn't shameful but on such a small dataset, I would have expected better considering that, AFAIK, that's all happening in memory.
So I would appreciate if some ArangoDB gurus out there could review my query and hint some potential performance issues. Thanks a lot!