Indexing Couchbase在扫描存储桶中的某些文档时出现性能问题-获取超时异常
我们有一个Indexing Couchbase在扫描存储桶中的某些文档时出现性能问题-获取超时异常,indexing,couchbase,spring-data-couchbase,Indexing,Couchbase,Spring Data Couchbase,我们有一个Couchbaseserver版本communityedition5.1.1build5723 在我们的汽车桶中,我们有汽车制造和它制造的汽车 两者之间的连接是carmake的Id,我们将其保存为Car文档中的另一个字段(如MySQL表中的外键) 这个bucket只有330000个文档 对于非常简单的查询,例如 select * from cars where model="Camry" <-- we expect to have about 50,000 results fo
Couchbase
server版本communityedition5.1.1build5723
在我们的汽车
桶中,我们有汽车制造
和它制造的汽车
两者之间的连接是carmake
的Id
,我们将其保存为Car文档中的另一个字段(如MySQL表中的外键)
这个bucket只有330000个文档
对于非常简单的查询,例如
select * from cars where model="Camry" <-- we expect to have about 50,000 results for that
我们可以在运行时看到该索引
SELECT * FROM system:indexes
我们错过了什么?在NoSQL数据库中进行此类查询的时间是否合理
CREATE INDEX model_idx ON cars(model);
您的索引不包括模型字段
您应该有spring DataCouchbase“\u class”属性的索引
我们就是这样解决这个问题的:
具有50k结果的查询不是简单的查询。你能用“解释”(explain)来公布你的查询结果吗?
CREATE INDEX model_idx ON cars(model);
CREATE INDEX `type_idx` ON `cars`(`_class`)
do{
Pageable pageable = PageRequest.of(pageNumber, SLICE_SIZE, Sort.by("id"));
Slice slice carsRepository.findAllByModelName("Camry", pageable);
List cars = slice.getContent();
} while (slice.hasNext());