I have a Springboot App that is using MongoDB as the database. One of the collections has a string field and query on that field is taking very long, I am unable to tune it. I have created index but still there is no improvement. Here is my code.
public interface MyTableRepository extends MongoRepository<MyTable, String> {
public List<MyTable> findByState(String state);
}
Here is my index:
db.getCollection('myTable').createIndex( { "state": 1 } )
When I run the following code form my service, this call returns about 800 rows & takes about 20 seconds.
List<MyTable> publishedItems = myRepository.findByState("published");