One index not working for multiple queries


#1

SELECT DISTINCT RAW categoryName FROM content WHERE _type = “UserAsset” AND type = “PUBLICAUDIO” ORDER BY categoryName

I am using this query with a index like
CREATE INDEX ix1c_UserAsset ON content(createdAt DESC,type,_type,status, name,tags,url,_id) WHERE _type=“UserAsset”

But because of this index the below delete Query is getting slow.
DELETE FROM content
WHERE _type=“UserAsset” AND _id=“887a35e9-81cc-40b3-bb0d-657a64caed81”

to over come this I modified the index like
CREATE INDEX ix1d_UserAsset ON content(_id)
WHERE _type=“UserAsset”;

and due to this index the above select statement is getting slow. Response time 29.59s.
Is there any other way to create an index so that both the query will execute with in mili seconds.Or I have to create two separate index for two queries.

Thanks


#2

You need separate index.

Check this out.
https://blog.couchbase.com/create-right-index-get-right-performance/
https://blog.couchbase.com/n1ql-practical-guide-second-edition/