We have a N1QL query is taking minutes to run, even we have an index for it. The explain shows the index is used, but it should not have as the performance indicates.
When I hint for another index, the performance improves too. Is possible that the index actually not in used? How can I tell?
select * from TA USE INDEX (company_index1) where _class = "aaa.bbb.ccc.ddd.eee"
AND idoc.header.cid = "12345"
AND idoc.header.uid = “5678”
CREATE INDEX company_index1 ON TA(_class,idoc.header.cid,idoc.header.uid,assignments.context) WHERE (_class = “aaa.bbb.ccc.ddd.eee”) USING GSI
EXPLAIN select * from TA USE INDEX (company_index1) where _class = "aaa.bbb.ccc.ddd.eee"
AND idoc.header.cid = "12345"
AND idoc.header.uid = “5678”
The Plan is not right. Try the following. The spans should have predicate values.
DROP INDEX TA.company_index1;
CREATE INDEX company_index1 ON TA(idoc.header.cid,idoc.header.uid,assignments.context) WHERE _class = "aaa.bbb.ccc.ddd.eee";
EXPLAIN select * from TA USE INDEX (company_index1) where _class = "aaa.bbb.ccc.ddd.eee"
AND idoc.header.cid = "12345" AND idoc.header.uid = "5678";
Hum. The change suggested makes sense. However, EXPLAIN shows that the primary index is used, instead of “company_index1”, after the change , therefore the performance still sucks.