I added around 900 document to couchbase of two types (Country and Rate
) and then trying to retrieve one type Country by extending CrudRepository
and using findAll
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);
}
I created the view all as requested but the result is taking around 10 second , is this normal , note that when I use other methods in RateRepository they are super fast .
I did create also primary index and GSI for top field in Rate .
How can I check if the speed issue is related to couchbase or spring-data ?
I couldn't figure out why view is that slow so i went to N1QL and it is much more faster i change the repostiory to be like below
public interface CountryRepository extends CrudRepository<Country, String> {
@Query("#{#n1ql.selectEntity} WHERE #{#n1ql.filter}")
List<Country> findAllCountries();
}
and used findAllCountries
instead of findAll