【问题标题】:Arangodb response of AQL slowAQL 的 Arangodb 响应缓慢
【发布时间】:2014-07-16 22:45:38
【问题描述】:

当我像这样进行嵌套查询时

FOR f in friends 
  FOR l in locations 
     FILTER l.friends_id == f.id
RETURN {'friends':f, 'locations':l}

(3484 个结果)。

响应很慢(在 7 到 10 秒之间)通过 Web 界面和 arangosh 返回结果

我的担心:这个响应时间是不是太大了?生产数据库会比这大得多,并且会带来性能问题。

有什么想法吗? 问候!

【问题讨论】:

    标签: arangodb


    【解决方案1】:

    我尝试了以下方法:

    arangosh [_system]> db._create("users");
    [ArangoCollection 1252513721, "users" (type document, status loaded)]
    
    arangosh [_system]> db._create("locations");
    [ArangoCollection 1252644793, "locations" (type document, status loaded)]
    
    arangosh [_system]> db._query("FOR i IN 1 .. 10000 INSERT { 'id': i, 'name': 'Name' } INTO users").toArray()
    [ ]
    
    arangosh [_system]> db._query("FOR i IN 1 .. 10000 INSERT { 'friends_id': i, 'name': 'Name' } INTO  locations").toArray()
    [ ]
    
    arangosh [_system]> db.locations.ensureHashIndex("friends_id")
    
    var a = db._query("FOR f IN users FOR l IN locations FILTER l.friends_id == f.id RETURN { 'u': f, 'l': l}")
    

    这将很快返回 1000 条记录。

    您可以执行“ensureHashIndex”并重试吗?现在是不是更快了?

    【讨论】:

    • “friend_id”未编入索引!执行“ensureHashIndex”后问题解决,谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多