in Education by
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)

1 Answer

0 votes
by
Are you checking data array has value5 or value6 or must present both. If you are looking for either value5 or value6 you should use as follows. The query use the index push all the three keys. You can Verify using EXPLAIN (check Spans) ANY v IN data SATISFIES v IN [value5, value6] END If you are looking for both value5 and value6 must present you must use as follows. The query use the index push all the three keys. But here two different index scans does Intersection (index row has only one value at a time) You can Verify using EXPLAIN (check Spans) ANY v IN data SATISFIES v=value5 END AND ANY v IN data SATISFIES v=value6 END If you don't want to intersection you can do following. The query use the index push all the three keys and value6 IN data filter applied post index scan ANY v IN data SATISFIES v=value5 END AND value6 IN data

Related questions

0 votes
    I need to Separate multiple Array entries with a newline. the names in the aray value. Again I want ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I have an array in one view controller that I want to send to two other view controllers - i am ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    I have an array in one view controller that I want to send to two other view controllers - i am ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    I have an array in one view controller that I want to send to two other view controllers - i am ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    1. Name the term which is used to join two separate arrays into a single array. 2. How are the following ... answer fast I want please Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    1. Name the term which is used to join two separate arrays into a single array. 2.How are the following ... ii) primitive type data Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    malo 4. Name the term which is used to join two separate arrays into a single array. 5. How are the following passed to the functions? Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    If I have a "Bill" entity, I might create that bill instance via REST API by assigning the food ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 3, 2022 in Education by JackTerrance
0 votes
    If I have a "Bill" entity, I might create that bill instance via REST API by assigning the food ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 14, 2022 in Education by JackTerrance
0 votes
    When an inorganic compound (X) having 3e-2e as well as 2e-2e bonds reacts with ammonia gas at a certain temperature ... similar to (X) Select the correct answer from above options...
asked Nov 29, 2021 in Education by JackTerrance
0 votes
    Name the compound which shows both electric and ferroelectric proporties. Select the correct answer from above options...
asked Jan 5, 2022 in Education by JackTerrance
0 votes
    A compound is compound by cation C and anion A. The anions hexagonal close packed (hcp) lattice and the cations occupy ... C 3 A 4 C Select the correct answer from above options...
asked Jan 2, 2022 in Education by JackTerrance
0 votes
    I have a simple components: const Sidebar = (props) => { ... } const SidebarLink = (props) => ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Name the compound that can be added to AgCl so as to produce cation vacancies. Select the correct answer from above options...
asked Jan 5, 2022 in Education by JackTerrance
0 votes
    Name the compound which shows anti-ferroelectric property. Select the correct answer from above options...
asked Jan 5, 2022 in Education by JackTerrance
...