这是密码:
START n=node:ACCOUNTS(ACCOUNT_ID={id})
MATCH (n)-[:PROVIDER]->(p)<-[r:ALERT]-()
RETURN r
ORDER BY {o} ASC
SKIP {s} LIMIT {l}
以下是执行计划:
ColumnFilter(symKeys=[" UNNAMEDS239765216", "n", "m", " UNNAMED3", "p", "r"], returnItemNames=["r"], _rows=50, _db_hits=0)
Slice(skip="{s}", _rows=50, _db_hits=0)
Top(orderBy=["SortItem(Cached( UNNAMEDS239765216 of type Any),true)"], limit="Add", _rows=50, _db_hits=0)
Extract(symKeys=["n", "m", " UNNAMED3", "p", "r"], exprKeys=[" UNNAMEDS239765216"], _rows=42563, _db_hits=0)
TraversalMatcher(trail="(n)-[ UNNAMED3:PROVIDER WHERE true AND true]->(p)<-[r:ALERT WHERE true AND true]-(m)", _rows=42563, _db_hits=614381)
ParameterPipe(_rows=1, _db_hits=0)
账户有提供者(一对多)并且提供者有传入警报关系。我只对选择这些关系感兴趣。
第一次执行需要:
2013-07-18 17:40:54,199 [main] INFO net.ahm.graph.dao.AlertDAO - >>>> GET ALERTS FOR ACCOUNT CYPHER TOOK: 4789 m-secs
相同查询的第 10 次执行需要(引擎被缓存,查询被参数化):
2013-07-18 17:41:15,431 [main] INFO net.ahm.graph.dao.AlertDAO - >>>> GET ALERTS FOR ACCOUNT CYPHER TOOK: 1586 m-secs
删除 ORDER BY 会导致以下执行计划和时间:
2013-07-20 23:45:09,317 [main] DEBUG net.ahm.graph.dao.AlertDAO - ColumnFilter(symKeys=["n", "m", " UNNAMED3", "p", "r"], returnItemNames=["r"], _rows=50, _db_hits=0)
Slice(skip="{s}", limit="{l}", _rows=50, _db_hits=0)
TraversalMatcher(trail="(n)-[ UNNAMED3:PROVIDER WHERE true AND true]->(p)<-[r:ALERT WHERE true AND true]-(m)", _rows=50, _db_hits=241)
ParameterPipe(_rows=1, _db_hits=0)
2013-07-20 23:45:09,317 [main] INFO net.ahm.graph.dao.AlertDAO - >>>> GET ALERTS FOR ACCOUNT CYPHER TOOK: 9 m-secs