检索arangodb中没有链接边的顶点 [英] retrieve vertices with no linked edge in arangodb

查看:78
本文介绍了检索arangodb中没有链接边的顶点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

检索所有在相关edge_collection中没有边的顶点的最佳方法是什么

What is the best way to retrieve all vertices that do not have an edge in a related edge_collection

我尝试使用以下代码,但是自arangodb 2.8以来,它的运行速度变得异常慢(在以前的版本中速度不是很快,但现在快了10倍左右).大约1000个边和3000个顶点的集合大小需要30秒钟以上的时间.

I've tried to use the following code but it's got incredibly slow since arangodb 2.8 (It was not really fast in previous versions but round about 10 times faster as now). It takes more than 30 seconds on collection sizes of around 1000 edges and around 3000 vertices.

FOR v IN vertex_collection  
    FILTER LENGTH( EDGES(edge_collection, v._id, "outbound"))==0
RETURN v._id

...

更新

...

玩了一会儿之后,我来到了下面的查询

After playing around a bit I came to the following query

LET vIDs = (FOR v IN vertex_collection
            RETURN v._id)
LET vEdgesFrom = (FOR e IN edge_collection
                  FILTER e._from IN vIDs
                  RETURN e._from)
FOR v IN vertex_collection
    FILTER v._id IN MINUS(vIDs, vEdgesFrom)
RETURN v._id

这是一个更快的方法(大约0.05s),但是看起来还是可以解决的(只是考虑我们需要查询的多个边缘集合).

This one is much faster (around 0.05s) but still looks like some kind of work around (just thinking of more than one edge collections we need to query against).

因此,我仍在寻找最好的方法来查找特定边集合中没有边的顶点.

So I'm still looking for the best method to find vertices having no edge in specific edge collections.

推荐答案

我的建议与之相似-而是使用

My sugestion was going to be similar - rather use joins than graph features.

FOR oneEdge IN edges
LET vertices=(FOR oneVertex IN vertices
        FILTER oneEdge._from == oneVertex._id OR
               oneEdge._to == oneVertex._id
        RETURN 1)
FILTER LENGTH(vertices) < 2
RETURN {v: vertices, e: oneEdge}

查找_from_to之一指向nil的所有边,然后将其删除.

to find all edges where one of _from and _to would point into nil, and then subsequently delete it.

请注意RETURN 1,这将减少内部查询传递的数据量.

Note the RETURN 1 which will reduce the amount of data passed up from the inner query.

这篇关于检索arangodb中没有链接边的顶点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆