Replies: 16 comments 1 reply
-
Can you share your specific index definition? |
Beta Was this translation helpful? Give feedback.
-
This looks like a duplicate of #2236 on further reflection. @willholley 's response there is accurate:
And as @garrensmith says:
I don't think we can improve this, but I'll leave it open for a bit to see if anyone has any ideas. |
Beta Was this translation helpful? Give feedback.
-
{
"index": {
"fields": [
"input.root"
]
},
"name": "foo-json-index",
"type": "json"
} |
Beta Was this translation helpful? Give feedback.
-
Unless I'm misunderstanding something, I thought that's what I tried with {
"selector": {
"$or": [
{
"input.root": "aimer"
},
{
"input.root": "etre"
}
],
"input.agent": {
"$in": [
"2-sg",
"1-sg"
]
},
"input.option": {
"$in": [
"conditionnel-present",
"indicatif-present"
]
}
}
} But the same thing happens, it appears to be searching through each record: |
Beta Was this translation helpful? Give feedback.
-
Every field in your query must be contained in the index. |
Beta Was this translation helpful? Give feedback.
-
In order to use If I change my index to: {
"index": {
"fields": [
"input.root",
"input.agent",
"input.option"
]
},
"name": "root-agent-option-json-index",
"type": "json"
} It still doesn't use my index: |
Beta Was this translation helpful? Give feedback.
-
I can't speak to the or/in portion specifically (I believe the comments from the other devs indicate you'll never get this work for those), but I can say that if your selector included |
Beta Was this translation helpful? Give feedback.
-
Hm, OK, in that case I guess I'm confused as to why adding the index for just Index{
"index": {
"fields": [
"root.input"
]
},
"name": "foo-json-index",
"type": "json"
} Before adding Index aboveAfter adding Index above |
Beta Was this translation helpful? Give feedback.
-
I'll hand it over to @garrensmith or @willholley who are in UTC-ish timezones and will respond tomorrow. |
Beta Was this translation helpful? Give feedback.
-
Thanks, I really appreciate your time looking at this! |
Beta Was this translation helpful? Give feedback.
-
@roedoejet One option is to install the text index plugin, which will give you native |
Beta Was this translation helpful? Give feedback.
-
OK, thanks for this. I would love to see this documented here. There is already a note about the regex operator not accepting indices, so I assumed that was the only operator to note wrt indices. What about my example with |
Beta Was this translation helpful? Give feedback.
-
The basic behaviour for iirc (@garrensmith can confirm, there is an optimization, whereby if all of the Text indexes can again be more efficient for this as they have richer support for disjoint selectors. |
Beta Was this translation helpful? Give feedback.
-
For reference, I found this by @garrensmith where he says the $in operator does use an index in some cases. It would be nice to get an update on this. |
Beta Was this translation helpful? Give feedback.
-
The
With selector:
Mango will choose the above index because you have In another case if you had an index like this:
And the same query:
Then mango will read everything from the |
Beta Was this translation helpful? Give feedback.
-
Yes it will
Get Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
From: Nuri <[email protected]>
Sent: Friday, July 17, 2020 7:26:11 AM
To: apache/couchdb <[email protected]>
Cc: garren smith <[email protected]>; Mention <[email protected]>
Subject: Re: [apache/couchdb] $or and $in operators do not seem to be using indices (#2856)
Thanks for the clarification Garren. Will this all be the same in CouchDB V4?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#2856 (reply in thread)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AABL2ATO7LA5VNYVI6Y6IADR37OHHANCNFSM4O5R4YAA>.
|
Beta Was this translation helpful? Give feedback.
-
Description
This seems similar to #2236, #1852, #1552 and #1549 but the solutions there don't seem to fix anything for me.
I have a small test database full of French conjugations (7300 records). Each conjugation should be able to be queried on the verb root, pronoun (aka
agent
), and some temporal option.Here is a reasonable example query:
If I run this without any indexing, the performance is (expectedly) bad and I get this helpful message:
So, I'm indexing on verb root like so:
If I run the query again, this dramatically improves the search time:
However, if I then use the
$in
operator (I also tried the$or
operator) then the search time skyrockets to 4-6 seconds:Steps to Reproduce
I supplied the steps above - I am using Fauxton for all of my testing/debugging.
Here is the
explain
json for the query:Note that the
start_key
is empty and theend_key
is<MAX>
. If it's just one root being looked up, I instead getExpected Behaviour
I would expect that there would be some interpretation of the query to first pull each indexed
root
and then run the remainingoption
andagent
conditions on those indices, but instead, it appears to just run all of these conditions on every record in the database.To hack my way around this (following #2236 (comment)), if my api receives multiple
root
values, I split them up, run individual queries and then join them before returning the response, but surely there must be a more relaxing way :)Your Environment
Beta Was this translation helpful? Give feedback.
All reactions