1

我将大约 900 个文档添加到两种类型 ( Country and Rate) 的沙发库中,然后尝试通过扩展CrudRepository和使用来检索一种类型 CountryfindAll

public interface CountryRepository extends CrudRepository<Country, String> {

}

.

public interface RateRepository extends CrudRepository<Rate, String> {


    List<Rate> findByTopTrue();

    List<Rate> findByCountryStartingWith(String country);

    List<Rate> findByCountryIsoCode(String isoCode);

}

我按照要求创建了所有视图,但结果大约需要 10 秒,这是否正常,请注意,当我在 RateRepository 中使用其他方法时,它们的速度非常快。

我还为 Rate 中的顶部字段创建了主索引和 GSI。

如何检查速度问题是否与 couchbase 或 spring-data 相关?

4

1 回答 1

0

我不明白为什么视图这么慢所以我去了 N1QL 并且它更快我将存储库更改为如下所示

public interface CountryRepository extends CrudRepository<Country, String> {
    @Query("#{#n1ql.selectEntity} WHERE #{#n1ql.filter}")
    List<Country> findAllCountries();
}

并使用findAllCountries而不是findAll

于 2016-06-06T05:11:55.710 回答