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

Support cte shared scan in TiFlash #9785

Open
windtalker opened this issue Jan 14, 2025 · 0 comments
Open

Support cte shared scan in TiFlash #9785

windtalker opened this issue Jan 14, 2025 · 0 comments
Labels
type/enhancement The issue or PR belongs to an enhancement.

Comments

@windtalker
Copy link
Contributor

Enhancement

In TiDB if a cte is used more than 1 time in query, it will generate a cte shared scan executor, so the cte itself will only be calulated once, and each reader read the result from cte shared scan.

Currently, TiDB convert cte shared scan into exchange sender/receiver in MPP mode, but exchange sender/receiver actually require that all the exchange reciver read data from the same exchange sender at the same time, and cte reader actually does not meet this requirement.
For example:

with cte as xxx
select * from cte a join cte b where a.id = b.id

In the above query, both build and probe side read from the same cte, but probe side will begin to read afte build side is done, which mean build side will read all the data from cte, after that probe side begin to read. If we change cte shared scan into exchange sender with 2 exchange receivers, the exchange sender expect 2 exchange receiver read data at the same time, if only 1 exchange receiver read data, the exchange sender will be blocked by the other exchange reciever, which will makes the query hangs forever.

So we need to redesign TiFlash support of cte shared read.

@windtalker windtalker added the type/enhancement The issue or PR belongs to an enhancement. label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

No branches or pull requests

1 participant