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”属性的索引


我们就是这样解决这个问题的:

  • 使用和@paralen answer,我们创建了几个加快查询速度的索引
  • 当我们知道返回的结果集很大时,我们修改了代码以使用分页,并得出如下结论:
  • 做{ Pageable Pageable=PageRequest.of(页码、切片大小、排序方式(“id”); 切片carsRepository.findAllByModelName(“凯美瑞”,可分页); List cars=slice.getContent(); }while(slice.hasNext());
    具有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());