-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(mango
): add allow_fallback
to control falling back to other indexes on _find
#4792
feat(mango
): add allow_fallback
to control falling back to other indexes on _find
#4792
Conversation
fcb727c
to
f13501e
Compare
f13501e
to
449edf0
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree. @rnewson, @willholley, @ricellis please comment if you have the time. |
I was under the impression that |
I do not want to respond on behalf of @willholley but in my understanding, in his respective comment he opposed to extending the |
if |
@rnewson do you mean that we shall extend this change to disabling the |
Yes. Remember this an opt-in in the request body by the user. They are asking us to not fallback; they want an error instead of inefficient execution. I do not understand @willholley's objection to this. |
I don't think this issue / PR has anything to do with query efficiency - only fixing the unclear semantics of I'm open to a discussion about if we want to / how to prevent use of inefficient indexes or, but that's much broader problem space in which I don't see |
449edf0
to
322a278
Compare
mango
): add allow_fallback
for user-specified indexes on _find
mango
): add allow_fallback
to control falling back to other indexes on _find
Hi,
I've personally gone off the idea of yet more flags inside the I see a fork in the road for
If we take the first path, then neither the new allow_fallback parameter or the existing use_index parameter would be necessary, we'd gladly deprecate them. If we take the second path, then we're making a bad idea worse. I would prefer to add |
I was under the impression that I believe that Now we have a tool at hand at least that can save users from running badly planned queries, which could be useful even after the enhancements you suggested in the first point above have been implemented. We could always deprecate it later, once we have a better view at which one of the branches has been eventually taken or it is deemed to be unnecessary. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a nice improvement that will improve the mango user experience.
👋 @garrensmith! |
I liked @rnewson's idea of a very simple/predictable view that uses the selector syntax instead of javascript so tried this: #5310. It's even simpler than proposed, as it just uses the As for this particular PR, I think it's fine. We already got As for the future of Anyway just my $0.02. Also 👋 to @garrensmith! |
It is not always beneficial for the performance if the Mango query planner tries to assign an index to the selector. User-specified indexes may save the day, but since they are only hints for the planner, fallbacks may still happen. Introduce the `allow_fallback` flag which can be used to tell if falling back to other indexes is acceptable when an index is explicitly specified by the user. When set to `false`, give up on planning and return an HTTP 400 response right away. This way the user has the chance to learn about the requested but missing index, optionally create it and try again. By default, fallbacks are allowed to maintain backwards compatibility. It is possible to set `allow_fallback` to `true` but currently it coincides with the default behavior hence becomes a no-op in practice. Fixes apache#4511
The `binary:split/2` function will split the input only at the first occurrence of the pattern which is not suitable for identifying each part of the index name, therefore validating it. Add the `global` option to fully break the index name into parts and let the related validation logic work as expected.
9c33dc4
to
c92c389
Compare
@pgj had a chat just now to go over our differences. I'm happy to see allow_fallback:true|false merged, and will do when CI finishes successfully. I do want us to follow up with either the I also think allow_fallback should default to |
Thank everyone who participated in the discussion. |
This is an alternative to #4710 based on the results of the related discussion.
It is not always beneficial for the performance if the Mango query planner tries to assign an index to the selector. User-specified indexes may save the day, but since they are only hints for the planner, fallbacks may still happen.
Introduce the
allow_fallback
flag which can be used to tell if falling back to other indexes is acceptable when an index is explicitly specified by the user or when only the "catch-all"all_docs
index could be picked. When set tofalse
, give up on planning and return an HTTP 400 response right away. This way the user has the chance to learn about the requested but missing index, optionally create it and try again.By default, fallbacks are allowed to maintain backwards compatibility. It is possible to set
allow_fallback
totrue
but currently it coincides with the default behavior hence becomes a no-op in practice.Fixes #4511
Testing recommendations
The changes could be verified by the following commands:
This is a non-breaking change, so there should be no observable difference in the behavior for the users. When
allow_fallback
is set tofalse
anduse_index
is set to some index, it may return HTTP 400 depending on the suitability of the given index.Checklist
src/docs
folder