【问题标题】:Neo4j cypher Recommendations Query Performance IssuesNeo4j 密码建议查询性能问题
【发布时间】:2017-09-15 00:26:26
【问题描述】:

我目前正在处理产品推荐查询,该查询应根据查看相似产品找到相似客户,然后推荐这些相似客户查看过的其他产品,返回产品以推荐给当前客户。我们的业务是寄售的,所以我们每个产品只有 1 件,所以我正在处理一个更大的数据集,在类似的视图中而不是仅仅购买。我期望这个查询应该能够在一秒钟内运行,因为它目前只针对我们开发环境中的 10k 多一点的产品和 10k 用户运行。我不确定是我的查询需要调整,还是 linux/java/neo4j 配置或两者兼而有之。有人有这方面的经验吗?

MATCH (currentUser:websiteUser{uuid: 'ea1d35e7-73e6-4990-b7b5-
2db24121da9b'})-[:VIEWED]->(i:websiteItem)<-[:VIEWED]-
(similarUser:websiteUser)-[r:VIEWED]->(similarItem:websiteItem 
{active: true})
RETURN similarItem.designer, similarItem.title, 
similarItem.brandSize, similarItem.sku, similarItem.shopifyProductId, 
similarItem.url, similarItem.price, COUNT(distinct r) AS score 
ORDER BY score DESC LIMIT 15

配置文件输出:

output of query profile image

【问题讨论】:

    标签: neo4j cypher


    【解决方案1】:

    经过进一步研究,并尝试了互联网上其他帖子的许多不同建议,这些建议与机器的性能调整和查询有关,我发现以下查询重写可提供基于重写查询的最佳速度步骤并使用 with distinct 来限制从一个查询段到下一个段的结果膨胀膨胀。

    MATCH (u:websiteUser{uuid: 'ea1d35e7-73e6-4990-b7b5-2db24121da9b'})
    MATCH (u)-[:VIEWED]->(i:websiteItem)
    WITH distinct i
    MATCH (i)<-[:VIEWED]-(su:websiteUser)
    WITH distinct su
    MATCH (su)-[r:VIEWED]->(si:websiteItem {active: true})
    RETURN si.designer, si.title, si.brandSize, si.sku, si.shopifyProductId, 
    si.url, si.price, COUNT(distinct r) AS score
    ORDER BY score DESC
    LIMIT 15
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-12-22
      • 2014-11-18
      • 1970-01-01
      • 1970-01-01
      • 2013-09-29
      • 2013-11-11
      • 1970-01-01
      • 2011-11-26
      相关资源
      最近更新 更多