I have the following query method.
findAllByProfile_UserIdContainingAndOrigin
There is an index for profile.userId but the query is extremely slow. I suspect that because of the Containing keyword the index is not being used efficiently since it has to check the profile.userId property of all documents for similar properties.
Is my suspicion correct? Is there a way to test this conclusively in a dev environment?
Clarification: The method has no body, it's a query method that is automatically converted into a query. https://docs.spring.io/spring-data/jpa/reference/jpa/query-methods.html
Example of the executed query:
{ "profile.userId" : { "$regularExpression" : { "pattern" : ".12345.", "options" : ""}}, "origin" : "user"} fields: Document{{}}