Is there a way to find the query that was run against the database in spring data mongodb?
I know this is possible in case of JPA. So was just wondering if there was something similar in Spring data MongoDB?
Yes, DataNucleus JPA allows it, as well as to many other databases.
@Document is an annotation provided by Spring data project. It is used to identify a domain object, which is persisted to MongoDB. So you can use it to map a Java class into a collection inside MongoDB. If you don't use Spring Data, you don't need this annotation.
Steps taken to try to reduce execution time: Only necessary fields are projected which reduced the time by 10-30% depending on the query. Tried to reduce the size of each document to only contain necessary and non-empty fields. Tried to make tags more selective.
logging:
level:
org.springframework.data.mongodb.core.MongoTemplate: DEBUG
To clarify Oliver's answer add that to the application.yml file or properties file.
The easiest way is to set the log level to DEBUG
for org.springframework.data.mongodb
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With