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

TPC: Remove unnecessary union tables #27957

Closed
smitpatel opened this issue May 5, 2022 · 1 comment · Fixed by #27993
Closed

TPC: Remove unnecessary union tables #27957

smitpatel opened this issue May 5, 2022 · 1 comment · Fixed by #27993
Assignees
Labels
area-perf area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Milestone

Comments

@smitpatel
Copy link
Member

SELECT [t].[Species], [t].[CountryId], [t].[Name], [t].[EagleId], [t].[IsFlightless], [t].[Group], [t].[FoundOn], [t].[Discriminator]
FROM (
    SELECT [e].[Species], [e].[CountryId], [e].[Name], [e].[EagleId], [e].[IsFlightless], [e].[Group], NULL AS [FoundOn], N'Eagle' AS [Discriminator]
    FROM [Eagle] AS [e]
    UNION ALL
    SELECT [k].[Species], [k].[CountryId], [k].[Name], [k].[EagleId], [k].[IsFlightless], NULL AS [Group], [k].[FoundOn], N'Kiwi' AS [Discriminator]
    FROM [Kiwi] AS [k]
) AS [t]
WHERE [t].[Discriminator] = N'Kiwi'

EF6 did condense this.

@smitpatel
Copy link
Member Author

Can only do for Where and it has to be at same level as source.

@smitpatel smitpatel self-assigned this May 6, 2022
@ajcvickers ajcvickers added this to the 7.0.0 milestone May 6, 2022
smitpatel added a commit that referenced this issue May 10, 2022
- Add TpcTablesExpression which holds all union all tables so we can prune unused subqueries
- Also allow pruning of unused column inside each subquery
- Assign unique aliases in inner subqueries across whole SelectExpression
- Apply predicate on discriminator column directly to subqueries by removing unnecessary subqueries

Resolves #27967
Resolves #27957
@smitpatel smitpatel added area-perf closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. labels May 10, 2022
smitpatel added a commit that referenced this issue May 11, 2022
- Add TpcTablesExpression which holds all union all tables so we can prune unused subqueries
- Also allow pruning of unused column inside each subquery
- Assign unique aliases in inner subqueries across whole SelectExpression
- Apply predicate on discriminator column directly to subqueries by removing unnecessary subqueries

Resolves #27967
Resolves #27957
smitpatel added a commit that referenced this issue May 11, 2022
- Add TpcTablesExpression which holds all union all tables so we can prune unused subqueries
- Also allow pruning of unused column inside each subquery
- Assign unique aliases in inner subqueries across whole SelectExpression
- Apply predicate on discriminator column directly to subqueries by removing unnecessary subqueries

Resolves #27967
Resolves #27957
@ajcvickers ajcvickers modified the milestones: 7.0.0, 7.0.0-preview5 May 25, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0-preview5, 7.0.0 Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-perf area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-enhancement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants