密码:使用WHERE子句或MATCH属性定义进行完全匹配吗? [英] Cypher: Use WHERE clause or MATCH property definition for exact match?

查看:66
本文介绍了密码:使用WHERE子句或MATCH属性定义进行完全匹配吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Neo4j(3.0版)中,以下查询返回的结果相同:

In Neo4j (version 3.0), the following queries return the same results:

1. MATCH (a:Label) WHERE a.property = "Something" RETURN a
2. MATCH (a:Label {property: "Something"}) RETURN a

在处理一些大型数据集时,我注意到(并使用EXPLAINPROFILE进行了验证),在某些情况下,第二个查询之类的查询性能更好,更快.虽然存在其他情况,两个版本的性能均相同,但我还没有看到第一个版本的性能更好.

While playing with some large datasets, I noticed (and verified using EXPLAIN and PROFILE) that for some instances, queries like the second one performs better and faster. While other instances exist where both versions performed equally, I didn't yet see one where the first version performed better.

neo4j文档和教程也有所不同.两者之间没有明确的比较. docs和tut使用这两个版本,通常倾向于第一个版本(可能是因为使用WHERE子句只能 进行不完全匹配).但是指南还指出,缩小搜索范围的越早,搜索速度就越快.

The neo4j documentation and tutorials are also divided. There's no explicit comparison between the two. The docs and tuts use both versions, often leaning towards the first (probably because non-exact matches can only be done using the WHERE clause). But the guidelines also state that the earlier you narrow down the search, the faster the search is.

  1. 我对吗,两个版本总是 返回相同的结果吗?
  2. 我对吗,第二个版本通常会更好地执行,因为它可以缩小搜索范围?

推荐答案

  1. 不,两者的评估结果基本上都是相同的查询计划.由于Neo4j使用基于成本的优化器,因此查询计划可能会随时间而改变,因为优化器会考虑进行更改(也许现在有更多数据,因此索引查找比NodeByLabelScan便宜).

这篇关于密码:使用WHERE子句或MATCH属性定义进行完全匹配吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆