Compound index (with array index) vs compound index and separate array index in couchbase N1QL Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Difference between CouchDB and CouchbaseThe grouping of the keys by nameUNION operation in Aerospike or CouchbaseCouchbase Query Execution time?Can I use TTL on members on couchbase documents?Couchbase N1QL: index and query on array fieldsN1QL performance with joinCustom MongoDB Object _id vs Compound indexCouchbase N1QL array queryN1ql query couchbase
Table formatting with tabularx?
How can I prevent/balance waiting and turtling as a response to cooldown mechanics
One-one communication
By what mechanism was the 2017 UK General Election called?
Determine whether an integer is a palindrome
Where and when has Thucydides been studied?
Can two people see the same photon?
What should one know about term logic before studying propositional and predicate logic?
Pointing to problems without suggesting solutions
What are some likely causes to domain member PC losing contact to domain controller?
New Order #6: Easter Egg
How to make an animal which can only breed for a certain number of generations?
Noise in Eigenvalues plot
How to make triangles with rounded sides and corners? (squircle with 3 sides)
What is "Lambda" in Heston's original paper on stochastic volatility models?
.bashrc alias for a command with fixed second parameter
How does TikZ render an arc?
How to ask rejected full-time candidates to apply to teach individual courses?
3D Masyu - A Die
Understanding piped commands in GNU/Linux
Flight departed from the gate 5 min before scheduled departure time. Refund options
Does the main washing effect of soap come from foam?
Twin's vs. Twins'
The Nth Gryphon Number
Compound index (with array index) vs compound index and separate array index in couchbase N1QL
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern)
Data science time! April 2019 and salary with experience
The Ask Question Wizard is Live!Difference between CouchDB and CouchbaseThe grouping of the keys by nameUNION operation in Aerospike or CouchbaseCouchbase Query Execution time?Can I use TTL on members on couchbase documents?Couchbase N1QL: index and query on array fieldsN1QL performance with joinCustom MongoDB Object _id vs Compound indexCouchbase N1QL array queryN1ql query couchbase
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
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
nosql couchbase n1ql
add a comment |
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
nosql couchbase n1ql
add a comment |
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
nosql couchbase n1ql
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
nosql couchbase n1ql
nosql couchbase n1ql
edited Mar 22 at 13:08
Gordon Linoff
800k37321426
800k37321426
asked Mar 22 at 13:00
Carlos FCarlos F
1,0992816
1,0992816
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
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
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55300192%2fcompound-index-with-array-index-vs-compound-index-and-separate-array-index-in%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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
add a comment |
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
add a comment |
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
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
answered Mar 22 at 18:36
vsrvsr
1,77946
1,77946
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55300192%2fcompound-index-with-array-index-vs-compound-index-and-separate-array-index-in%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown