mongodb - Spring MongoDB 复合索引覆盖率
问题描述
我有一个包含字段engine
, type
,的文档manufacturerId
。我在 3 个字段上创建了一个复合unique
索引,所以我使用以下内容来创建索引。
@CompoundIndex(name = "engine_type_manufacturerId", def = "{'engine' : 1, 'type' : 1, 'manufacturerId': 1}", unique = true)
这样可以避免 3 个字段的组合出现重复条目。
继续前进,在我的应用程序中,我有查询,我只能通过engine
或搜索engine & type
。现在,我的问题是,我之前创建的复合唯一索引是否会涵盖查询的情况,engine
或者engine & type
我应该为这些情况创建新索引吗?
解决方案
推荐阅读
- python - 正则表达式:匹配特定模式,如果匹配在特定上下文中则排除
- sql - 在sql server中将行转换为列
- php - 语法错误,当尝试像 localhost/project_name/public 一样运行时,laravel 中出现意外的“版本”(T_STRING)
- javascript - 材质对话框返回多个对象
- c# - 当从 C# 编写的服务调用时,Process.Start() 什么也不做
- validation - Spring Test mockMvc 忽略验证
- jquery - 尝试使用 html5 模式添加验证
- javascript - 在javascript中注册一个更改html输入值的事件
- java - 无法在eclipse中创建简单的java restapi
- java - XML 解组到 Java/Kotlin 中的对象