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

Feature: adaptive enable materialized CTE #16833

Open
Tracked by #16867
xudong963 opened this issue Nov 13, 2024 · 1 comment
Open
Tracked by #16867

Feature: adaptive enable materialized CTE #16833

xudong963 opened this issue Nov 13, 2024 · 1 comment
Assignees

Comments

@xudong963
Copy link
Member

Summary

Currently, M CTE relies on the MATERIALIZED keyword to enable.

Add heuristic rules in the optimizer to make it adaptive, then users don't need to decide when to use materialized cte.

@xudong963
Copy link
Member Author

xudong963 commented Dec 10, 2024

Some high prior rules:

1(Pre). process cte at the optimizer phase not the binder phase
2. always inlining single-use CTEs
3. elimination of unused CTEs
4. push down predicates even without inlining ctes

For 4, there is an example:

WITH v as (SELECT i brand, i color FROM item WHERE i current price < 50)
SELECT * FROM v v1, v v2 WHERE v1.i brand = v2.i brand AND v1.i color = ’red’
AND v2.i color = ’blue’;

If v is materialized, we can still push down filter to the materialized cte, the pushed filter is v1.i color = ’red’ or v2.i color = ’blue’

After those rules, we can do tpcds benchmark for: 01, 02, 04, 05, 11, 14, 18, 22, 23, 24, 27, 30, 31, 36, 39, 47, 51, 58, 58, 64, 67, 70, 74, 75, 80, 83, 86, 95, 97.

cc @Dousir9

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

1 participant