N1QL Query times out when Using parameterized IN clause

狂风中的少年 提交于 2019-12-05 02:59:06

I found the issue it has to do with the parameterization of the values in the IN clause. When I removed the parameterization from the query I was able to run as fast as CBQ. My only option was to drop parameterizing.I Attempted to adjust the secondary index a bit moving the ParentMsgId to the end of the fields list this did not help in my case.

The underlying problem diagnosed from couchbase rep.

the underlying issue is that once you put the IN values in a parameter, the optimiser can't assume the IN clause only has one value. Since experienceId leads the index, we can only use an equality to travel down the index and start counting the keys that apply because we would have to skip and scan. I would suggest creating the index as (docType, publishTimestamp, ParentMsgId), that way we can still scan the index on the conditions set on docType, publishTimestamp, and apply the filter on experienceId later on in the pipeline.

Can you check/post the EXPLAIN output for this query. Also, check the query/index logs on server (and no networking delays).

running my app from AWS I get a TimeOutException it is only this query which is timing out others are not.

Are both client/app and CB/server in AWS??

And, post the other query which is working in this setup. What is unique about this query that isn't working??

-Prasad

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!