2014-07-16 38 views
2

当我这样做这样Arangodb响应慢

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

(3484个结果)嵌套查询。

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

我关心:这个响应时间是不是太大了?生产数据库将比这更大,并且可能带来性能问题。

有什么想法? 关心!

回答

2

我已经试过如下:

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”并重试吗?现在速度更快吗?

+0

“friend_id”未被索引!执行“ensureHashIndex”后问题解决了,谢谢! – Tarsis