2017-09-13 192 views
1

我目前正在研究产品推荐查询,该查询应根据查看类似产品找到类似客户,然后建议那些类似客户查看的其他产品,向当前客户推荐产品。我们的业务处于托运状态,因此我们只有每件产品中有1件,因此我正在使用类似视图中的较大数据集,而不仅仅是采购。我期望这个查询应该能够在第二秒钟内完好运行,因为它只能运行在我们的开发环境中的超过10k个产品和10k个用户上。我不确定是否需要调整我的查询,linux/java/neo4j配置或两者。有没有人有这方面的经验?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

回答

0

做一些进一步的研究,以及来自全国各地有关本机的两个性能优化和我已经在上网查询其他职位尝试许多不同的建议后发现以下查询重写以基于逐步重写查询并使用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