Let's say I have a Decision base node with a defined ID:
假设我有一个具有已定义ID的决策基节点:
@NodeEntity
public class Decision {
@Id
@Index(unique = true)
private Long id;
}
I have defined a UNIQUE INDEX on Decision.id
.
我已经在Decision.id上定义了唯一索引。
Additionally, I have two nodes derived from Decision:
此外,我还有两个从Decision派生的节点:
@NodeEntity
public class Profile extends Decision {
}
@NodeEntity
public class Notification extends Decision{
}
Let's consider a scenario where I have 1000 Profiles
in my database and 1 billion Notifications
. Will querying Profiles by a Cypher query be significantly affected by the presence of 1 billion Notification nodes because they share the same common label 'Decision'?
让我们考虑这样一个场景:我的数据库中有1000个配置文件和10亿个通知。通过Cypher查询查询配置文件是否会因10亿个通知节点的存在而受到重大影响,因为它们共享相同的公共标签‘Decision’?
Should I also add a UNIQUE INDEX on 'Profile.id' and 'Notification.id,' even if they inherit it from the 'Decision' node?
我是否还应该在‘Profile.id’和‘Notification.id’上添加唯一索引,即使它们是从‘Decision’节点继承的?
更多回答
优秀答案推荐
A uniqueness constraint creates a RANGE index. RANGE indexes internally use the B+ tree algorithm, which have O(log n) complexity.
唯一性约束创建范围索引。范围索引在内部使用B+树算法,其复杂度为O(Logn)。
log2
of 1K is about 10, and log2
of 1G is about 30. It is up to you to decide whether a factor of 3 is significant enough to warrant creating another index. Creating an extra index for only 1K nodes should not take up much storage, so that should not be a concern. You may want to try it to see if it is worth it.
1K的log2约为10,1G的log2约为30。3的系数是否足够重要,足以保证创建另一个指数,这取决于您。仅为1K节点创建额外的索引应该不会占用太多存储,因此这不应该是一个问题。你可能想试一试,看看它是否值得。
更多回答
Agreed. Nothing beats an experiment to test what works best!!
同意。没有什么比测试什么效果最好的实验更好了!
我是一名优秀的程序员,十分优秀!