One of the ways to improve your application performance in Couchbase is to create indexes for common queries. However, when you are working with Spring Data using its standard DSL, the generated query is not very clear, which makes a little bit more difficult to create the right index to it.

This problem can be easily solved by enabling DEBUG log level in the class AbstractN1qlBasedQuery, it will print the generated N1QL query in the log, a behavior very similar to enabling the attribute show_sql in Hibernate.  Here is how you can set this configuration in your application.yml

You can also enable it via logback  by simply adding it as a dependency:

And then, add the logback.xml configuration file in your resources folder:

When you run your application again, the generated N1QL queries will be printed in the logs.

 

If you have any questions, ping me at @deniswsrosa

 

 

Posted by Denis Rosa, Developer Advocate, Couchbase

Denis Rosa is a Developer Advocate for Couchbase and lives in Munich - Germany. He has a solid experience as a software engineer and speaks fluently Java, Python, Scala and Javascript. Denis likes to write about search, Big Data, AI, Microservices and everything else that would help developers to make a beautiful, faster, stable and scalable app.

Leave a reply