What is the performance, disk usage and speed of a compound index(with an array index) and a compound index with a separate array index?
Lets say I have a document with a structure similar to this
key1:value1,
key2:value2,
key3:value3,
key4:value4,
data:[
value5,
value6,
value7,
},
key8:value8
From what I understand of Couchbase N1QL if I create an index and query similar to:
CREATE INDEX indx_data ON document(key1,key4, ALL DISTINCT ARRAY v FOR v IN data END
SELECT * FROM document WHERE key1=value1 AND key4=value4 AND ANY v IN data SATISFIES v=value5 END AND ANY v IN data SATISFIES v=value6
The first part of the index will be used on the query but with the second value for data(ANY v IN data SATISFIES v=value6) the index will not be used? So would it be better to have an index for key1 and key4 and then a separate index for the array to be able to compare it? Or is there a way to use the compound index including the array?
Also another question that just popped up:
It is better to have a document to index as I just presented or similar to:
key1:value1,
key2:value2,
key3:value3,
key4:value4,
data:{
key5:value5,
key6:value6,
key7:value7,
},
key8:value8
This question is also performance
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)