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

Solve I_S queries using CNF rewriting #7677

Merged
merged 8 commits into from
Mar 21, 2021
Merged

Conversation

systay
Copy link
Collaborator

@systay systay commented Mar 13, 2021

Description

To handle I_S queries correctly, we need to be able to find the table_schema and table_name predicates in the WHERE clause. Sometimes, this is difficult because of how the query is written.

What this PR does is to introduce a rewriter that is able to massage boolean logic into a simpler form. It normalises the predicates into a form that the planner is looking for, and this makes it possible for the planner to find more applicable rules.

CNF, short for conjuctive normal form, rewrites the predicates into an AND of ORs, which is exactly what the planner is looking for.

Related Issue(s)

Fixes: #7377

Checklist

  • Should this PR be backported? Nope
  • Tests were added or are not required Added
  • Documentation was added or is not required Not needed

Impacted Areas in Vitess

Components that this PR will affect:

  • Query Serving

@systay
Copy link
Collaborator Author

systay commented Mar 15, 2021

@pontusmelke am I doing it right? ;)

@systay systay changed the title CNF rewriter Solve I_S queries using CNF rewriting Mar 15, 2021
@systay systay marked this pull request as ready for review March 15, 2021 14:32
@systay
Copy link
Collaborator Author

systay commented Mar 15, 2021

We could use this strategy in more situations - we could replan when we encounter Scatter queries, vtgate joins and probably some more.

go/vt/vtgate/planbuilder/plan_test.go Outdated Show resolved Hide resolved
go/vt/vtgate/planbuilder/plan_test.go Outdated Show resolved Hide resolved
@systay systay merged commit 33bf918 into vitessio:master Mar 21, 2021
@systay systay deleted the cnf-rewriter branch March 21, 2021 16:25
@pontusmelke
Copy link

@pontusmelke am I doing it right? ;)

Still got it 💥

@askdba askdba added this to the v10.0 milestone Mar 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants