【问题标题】:Neo4j merge performanceNeo4j 合并性能
【发布时间】:2014-11-13 23:45:17
【问题描述】:

我有一个数据导入引擎,可以查询 API 的社交数据,并将其处理到 Neo4j 中

我正在使用 MERGE 查询来创建/更新 UserActivity 节点,并将它们与联系人相关联,如下所示:

MATCH 
  (profile:SocialProfile {profile_id:20})-[:`RELATES_TO`]->(user:Contact) 
MERGE  
  (user)-[r:`USER_ACTIVITY`]->(activity:UserActivity {useractivity_id: '20_532181000298962040'})
ON CREATE SET
  r = {is_new: true, date_created: '2014-11-11 16:03:05'},
  activity = {date: '2014-11-11 14:40:12', text: 'hi man hope all is well!', user: '{"identifier":289883222,"displayName":"foomanchu","profileURL":"http:\\/\\/twitter.com\\/foomanchu","photoURL":"http:\\/\\/pbs.twimg.com\\/profile_images\\/474234438473353985\\/Rbp-7K33_normal.png"}', to: null, to_id: null, type: 'feed', relates_to: null, num_replies: null, num_likes: null, num_retweets: 1, num_favorites: 3, is_liked: false, is_favorited: false, author_self: null, media_type: 'link', media_embed_url: "http://ow.ly/Ez3Dt", media_action_url: "http://ow.ly/Ez3Dt", remote_uid: 532181000298962040, useractivity_id: '20_532181000298962040', service: 'Twitter', datetime: 1415716812, author_remote_uid: 289883222}
ON MATCH SET
  activity = {date: '2014-11-11 14:40:12', text: 'hi man hope all is well!', user: '{"identifier":289883222,"displayName":"foomanchu","profileURL":"http:\\/\\/twitter.com\\/foomanchu","photoURL":"http:\\/\\/pbs.twimg.com\\/profile_images\\/474234438473353985\\/Rbp-7K33_normal.png"}', to: null, to_id: null, type: 'feed', relates_to: null, num_replies: null, num_likes: null, num_retweets: 1, num_favorites: 3, is_liked: false, is_favorited: false, author_self: null, media_type: 'link', media_embed_url: "http://ow.ly/Ez3Dt", media_action_url: "http://ow.ly/Ez3Dt", remote_uid: 532181000298962040, useractivity_id: '20_532181000298962040', service: 'Twitter', datetime: 1415716812, author_remote_uid: 289883222}

一些注意事项:
- 我们说的是一个有 50 万个节点的数据库,所以它真的很小。
- 在具有数字海洋(8 GB RAM,4 核)的云服务器上大约需要 1,000 毫秒
- 在我使用 1 年以上的笔记本电脑上,在具有 1.5 GB RAM 的 VM 中,大约需要 350 毫秒(仍然很慢,但没有那么慢)。
-我不确定为什么会出现差异,因为另一台服务器(理论上)要强大得多。
- 在两种环境中,数据库是相同的(压缩数据文件夹并在测试之前将其复制),但速度存在显着差异。

我想知道几件事:
1. 有什么办法可以优化查询吗?我已经有关于 profile_id 和 useractivity_id 的索引
2. 有什么实用的硬件/JVM/neo4j 性能建议?我正在为 Neo4J 性能调整指南文档苦苦挣扎。

提前致谢。

【问题讨论】:

    标签: neo4j


    【解决方案1】:

    是的,您可以做几件事:

    1. 您的索引策略是什么?您是否已将 SocialProfile-profile_id 属性编入索引?

    2. 使用查询参数,因此密码查询可以独立于传递的参数进行缓存

    3. 对于第一次匹配,您可以先单独匹配socialprofile,使用标签+索引属性profile_id,然后将模式匹配到用户:

      匹配 (个人资料:SocialProfile {profile_id:20}) 带配置文件 匹配(个人资料)-[:RELATES_TO]->(用户:联系人) ...

    克里斯

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多