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

Pushdown LIMIT to UNION ALL query #23288

Closed
wants to merge 2 commits into from
Closed

Conversation

ucasfl
Copy link
Collaborator

@ucasfl ucasfl commented Apr 19, 2021

I hereby agree to the terms of the CLA available at: https://yandex.ru/legal/cla/?lang=en

Changelog category (leave one):

  • Performance Improvement

Changelog entry (a user-readable short description of the changes that goes to CHANGELOG.md):

Pushdown LIMIT to UNION ALL query. closes #23239.

Detailed description / Documentation draft:

:) explain syntax SELECT * FROM (SELECT * FROM numbers(100) ORDER BY number union all select * from numbers(100) order by number ) 
ORDER BY number LIMIT 10                                                                                                                          
                                                                                                                                                  
EXPLAIN SYNTAX                                                                                                                                    
SELECT *                                                                                                                                          
FROM                                                                                                                                              
(                                                                                                                                                 
    SELECT *                                                                                                                                      
    FROM numbers(100)
    ORDER BY number ASC
    UNION ALL
    SELECT *
    FROM numbers(100)
    ORDER BY number ASC
)
ORDER BY number ASC
LIMIT 10

Query id: d470df8c-fd26-40ce-b27e-76633c8be785

┌─explain─────────────────┐
│ SELECT number           │
│ FROM                    │
│ (                       │
│     SELECT number       │
│     FROM numbers(100)   │
│     ORDER BY number ASC │
│     LIMIT 10            │
│     UNION ALL           │
│     SELECT number       │
│     FROM numbers(100)   │
│     ORDER BY number ASC │
│     LIMIT 10            │
│ )                       │
│ ORDER BY number ASC     │
│ LIMIT 10                │
└─────────────────────────┘

15 rows in set. Elapsed: 0.015 sec.

@robot-clickhouse robot-clickhouse added the pr-performance Pull request with some performance improvements label Apr 19, 2021
@@ -18,7 +18,7 @@ void NormalizeSelectWithUnionQueryMatcher::getSelectsFromUnionListNode(ASTPtr &
getSelectsFromUnionListNode(child, selects);

return;
}
}
Copy link
Collaborator Author

@ucasfl ucasfl Apr 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change in here just because an unrelated format issue.

@ucasfl ucasfl marked this pull request as draft April 19, 2021 08:39
@ucasfl ucasfl closed this Apr 30, 2021
@anotherbugmaster
Copy link

@ucasfl have you decided to close this because there are better ways to solve the issue or for other reasons?

@alexey-milovidov
Copy link
Member

@ucasfl, why closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-performance Pull request with some performance improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

LIMIT pushdown to UNION ALL queries
4 participants