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

Could we have an optimizer to deduplicate joins? #13409

Closed
alvinwo opened this issue Jul 29, 2022 · 3 comments
Closed

Could we have an optimizer to deduplicate joins? #13409

alvinwo opened this issue Jul 29, 2022 · 3 comments
Labels
enhancement New feature or request performance

Comments

@alvinwo
Copy link

alvinwo commented Jul 29, 2022

Like we've discussed in #13160

when we have a query like this:

SELECT a.id_user, a.name, SUM(b.value)
FROM (
  SELECT b.id_user_anon AS id_user, a.name
  FROM user a
  JOIN mapping b
  ON a.id_user = b.id_user
) a
JOIN (
  SELECT b.id_user_anon AS id_user, a.value
  FROM order a
  JOIN mapping b
  ON a.id_user = b.id_user
) b
ON a.id_user = b.id_user
GROUP BY 1,2
;

Could we deduplicate join mapping twice and only join it once, like

SELECT b.id_user_anon AS id_user, a.name, SUM(b.value)
FROM (
  SELECT a.id_user, a.name, b.value
  FROM user a
  JOIN order b
  ON a.id_user = b.id_user
) a
JOIN mapping b
ON a.id_user = b.id_user
GROUP BY 1, 2

cc @findepi

@findepi findepi added enhancement New feature or request performance labels Jul 29, 2022
@findepi
Copy link
Member

findepi commented Jul 29, 2022

@sopel39
Copy link
Member

sopel39 commented Jul 29, 2022

I think this is duplicate of #5878

@sopel39
Copy link
Member

sopel39 commented Oct 4, 2022

Closing as duplicate

@sopel39 sopel39 closed this as completed Oct 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request performance
Development

No branches or pull requests

3 participants