Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
552 views
in Technique[技术] by (71.8m points)

Spring Data MongoDB query performance is slower with respect to MongoDB Compass

I'm fetching records of around 1200 records, if I query it from Mongo Compass, it uses the Compound Index which I created, and from 20ms(without indexing) to 0ms the performance shows, but If I use the same query in my Spring Boot Java project using Document class and using the below query, it takes up to 2 secs to fetch the same record.

To create indexes I used to db.collectionName.createIndex()

Below is the Java Spring Data Query

@Query(value="{country:?0, age: ?1}",fields="{'name':1,'state':1}")
public List<Object> getcountrySpecificName(String country, String name);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...