ArangoDB:如何在社区版中并行运行2个查询

rur96b6h  于 2022-12-09  发布在  Go
关注(0)|答案(1)|浏览(114)

你好,我写了下面两个查询,我想并行运行这些查询,而不是顺序执行它们。在ArangoDB的社区版中可以并行执行它们吗?

FOR d IN Transaction
        FILTER d._to == "Account/123" 
        COLLECT AGGREGATE length = COUNT_UNIQUE(d._id), 
                          totamnt = SUM(d.Amount),
                          daysactive = COUNT_UNIQUE(DATE_TRUNC(d.Time, "day"))
        RETURN { 
            "Incoming Accounts": length , 
            "Days Active": LENGTH(daysactive), 
            "Total Amount": totamnt 
        }
        
FOR d IN Transaction
        FILTER d._from == "Account/123" 
        COLLECT AGGREGATE length = COUNT_UNIQUE(d._id), 
                          totamnt = SUM(d.Amount),
                          daysactive = COUNT_UNIQUE(DATE_TRUNC(d.Time, "day"))
        RETURN { 
            "Outgoing Accounts": length , 
            "Days Active": LENGTH(daysactive), 
            "Total Amount": totamnt 
        }
6ovsh4lw

6ovsh4lw1#

当然,并行运行多个请求是可能的,只需向_api/cursor发出两个curl调用,或者使用两个不同的arangosh shell。
或者在同一个shell中运行2个curl调用,并对每个请求使用x-arango-async头来异步检索结果,如下所示:https://www.arangodb.com/docs/stable/http/async-results-management.html#async-execution-and-later-result-retrieval

相关问题