Please take this survey to help us learn more about how you use third party tools. Your input is greatly appreciated!

UNION ALL very slow

BHIFPBHIFP
edited November 2021 in General Discussion

Running below, where both b and p are rather complex, but individually each are quite fast, however running UNION ALL is very slow:

This seems to be a well known issue with sql in general, for example:
https://stackoverflow.com/questions/44055834/simple-sql-union-all-very-slow
https://stackoverflow.com/questions/38373206/multiple-union-alls-unbearably-slow

Wonder what would be Vertica's solution? Thanks

Answers

  • Bryan_HBryan_H Administrator

    @BHIFP Is it possible to rewrite the query, or rewrite the logic calling the query?
    We've improved the performance of Common Table Expressions with temp relations so I wonder if the query could be written with "b" and "p" as materialized sub-queries in a WITH clause.
    Alternately, if the individual queries run quickly, it might be possible to create a temp table to hold the results of the individual queries then select from the temp table. The caller would have to implement that or use a stored procedure to generate the temp result set.
    This would be a good question for engineering at Unify coming up next week in Boston or later in the month in Paris.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file

Can't find what you're looking for? Search the Vertica Documentation, Knowledge Base, or Blog for more information.