Skip to content
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

AndWithThenPlanner does not handle OneOfThemWithComponent expressions #1876

Closed
alecgrieser opened this issue Oct 20, 2022 · 0 comments · Fixed by #1877
Closed

AndWithThenPlanner does not handle OneOfThemWithComponent expressions #1876

alecgrieser opened this issue Oct 20, 2022 · 0 comments · Fixed by #1877
Assignees
Labels
bug Something isn't working planner Related to the query planner

Comments

@alecgrieser
Copy link
Contributor

Within the RecordQueryPlanner, the AndWithThenPlanner does not handle OneOfThemWithComponents. In practice, this means that if you had a record type like:

message ExampleType {
    message NestedType {
        optional string value = 1;
    }
    optional int64 id = 1;
    repeated NestedType parent = 2;
    optional int64 other = 3;
}

And a value index with an expression like:

concat(field("other"), field("parent", FanType.FanOut).nest("value"))

Then you'd expect that index to satisfy the following query:

RecordQuery.newBuilder()
    .setRecordType("ExampleType")
    .setFilter(Query.and(
        Query.field("other").equalsParameter("o"),
        Query.field("parent").oneOfThem().matches(Query.field("value").equalsParameter("v"))
     ))
     .build();

However, because the AndWithThenPlanner ignores OneOfThemWithComponents, this will get planned some other way (for example, using a less efficient index or scanning the record store).

@alecgrieser alecgrieser added bug Something isn't working planner Related to the query planner labels Oct 20, 2022
alecgrieser added a commit to alecgrieser/fdb-record-layer that referenced this issue Oct 20, 2022
…WithComponent expressions

This adds support to the old planner to address a shortcoming where certain queries were choosing to use less efficient indexes due to a shortcoming with the `AndWithThenPlanner`. Based on the tests in the `NestedFieldQueryTest`, it looks like the new planner was already matching such expressions in this case, and so this shortcoming should only be in the old planner.

This fixes FoundationDB#1876.
@alecgrieser alecgrieser self-assigned this Oct 20, 2022
alecgrieser added a commit to alecgrieser/fdb-record-layer that referenced this issue Oct 27, 2022
…WithComponent expressions

This adds support to the old planner to address a shortcoming where certain queries were choosing to use less efficient indexes due to a shortcoming with the `AndWithThenPlanner`. Based on the tests in the `NestedFieldQueryTest`, it looks like the new planner was already matching such expressions in this case, and so this shortcoming should only be in the old planner.

This fixes FoundationDB#1876.
alecgrieser added a commit to alecgrieser/fdb-record-layer that referenced this issue Oct 31, 2022
…WithComponent expressions

This adds support to the old planner to address a shortcoming where certain queries were choosing to use less efficient indexes due to a shortcoming with the `AndWithThenPlanner`. Based on the tests in the `NestedFieldQueryTest`, it looks like the new planner was already matching such expressions in this case, and so this shortcoming should only be in the old planner.

This fixes FoundationDB#1876.
MMcM added a commit that referenced this issue Oct 31, 2022
…fthemwithcomponent

Fixes #1876: AndWithThenPlanner does not handle OneOfThemWithComponent expressions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working planner Related to the query planner
Projects
None yet
1 participant