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

Add join table reference check in JOIN ON clause when the columns are specified without table name or alias #17382

Closed
rmarduga opened this issue Mar 1, 2022 · 2 comments

Comments

@rmarduga
Copy link
Contributor

rmarduga commented Mar 1, 2022

Often times, while specifying the joining condition in JOIN ON clause, users make mistakes and not referencing the joining table along side with other table in join condition that result in performance issue due to conditional join resulting in CROSS JOIN.

#17333 partially addresses this issue by analyzing the queries that in JOIN ON condition specify the columns with the table directly (via table name or alias) and showing the user PERFORMANCE_WARNING if the conditional join resulted in a CROSS JOIN. However, it does not cover the cases when JOIN ON condition specifies the columns without referencing the table as in the examples below.

  1. SELECT * FROM table1 LEFT JOIN table2 ON a=b
  2. SELECT * FROM table1 LEFT JOIN (SELECT * FROM table2) ON a=b
@rmarduga rmarduga changed the title Add join table reference check in JOIN ON clause for the case when the columns are specified without directly referencing table or alias Add join table reference check in JOIN ON clause when the columns are specified without table name or alias Mar 1, 2022
@kaikalur
Copy link
Contributor

kaikalur commented Mar 1, 2022

#17333 is good for giving really precise error messages for copy/paste cases. We can do a more comprehensive check in the planner to make sure there are no cross joins - for example when we change a left/right/inner join a cross join we can give a warning saying we are creating a cross join due to bad join conditions.

rmarduga pushed a commit to rmarduga/presto that referenced this issue Mar 11, 2022
Often times, while specifying the joining condition in JOIN ON clause,
users make mistakes and not referencing the joining table along side
with other table in join condition that result in performance issue due
to conditional join resulting in CROSS JOIN.

This change will extend the number of cases when user is shown the
PERFORMANCE_WARNING when JOIN ON clause misses the comparison expression
with joining table and other table. Specifically, it covers the cases
when  user does not explicitly refer to the relation through table name
or alias in JOIN ON clause.

Resolves:prestodb#17382
See also: prestodb#17333
highker pushed a commit that referenced this issue Mar 11, 2022
Often times, while specifying the joining condition in JOIN ON clause,
users make mistakes and not referencing the joining table along side
with other table in join condition that result in performance issue due
to conditional join resulting in CROSS JOIN.

This change will extend the number of cases when user is shown the
PERFORMANCE_WARNING when JOIN ON clause misses the comparison expression
with joining table and other table. Specifically, it covers the cases
when  user does not explicitly refer to the relation through table name
or alias in JOIN ON clause.

Resolves:#17382
See also: #17333
@rmarduga
Copy link
Contributor Author

The issue was fixed by #18041

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants