count - Optimal way of join with counting Arango -


i wanted write efficent query in arango query language working join counting.

in database have users, tags , usertag collections. users , tags connected 'edge' stored in usertag. want list tags (with data tags collection) , each tag - number of users connected tag.

what have (it works):

for tag in tags     let foronetag = (       v, e, p in 1 outbound tag       usertag         return {e}     )     return {tag: tag.tagname, numberofusers: length(foronetag)} 

i feel not efficient way regarding time , memory. there more 'arangoic' way of doing it?

your query good. 1 small optimisation: use return e instead of return {e}, don't have wrap e inside document because it's document.

for tag in tags   let foronetag = (     v, e, p in 1 outbound tag       usertag       return e     )   return {tag: tag.tagname, numberofusers: length(foronetag)} 

alternatively use following query. these query more performant returns tags has @ least 1 connected user.

for tag in tags   v, e, p in 1 outbound tag     usertag     return {tag: tag.tagname, numberofusers:length(p.edges)} 

Comments

Popular posts from this blog

html - How to set bootstrap input responsive width? -

javascript - Highchart x and y axes data from json -

javascript - Get js console.log as python variable in QWebView pyqt -