Skip to content
Advertisement

Error while running very long SQL query with UNION ALL operator in Vertica

This is a sample of subquery used in Vertica Query which is a string generated from the application.

There are some cases when this subquery becomes huge as the number of rows with UNION ALL increases. Vertica supports this query to some extent. But when there is let’s say 3000 + UNION ALL operator used in a subquery it throws an error.

[SQL Error [4963] [54001]: [Vertica]VJDBC ERROR: The query contains a SET operation tree that is too complex to analyze

I could not find any documents that talk about the limited use of UNION ALL operator in query or length of the query string.

Is there any system parameter in Vertica or Linux for which we can change the value to successfully execute the query?

I have an alternate approach to fix the query removing UNION ALL. But looking for a solution to the error generated.

Thanks in Advance!

Advertisement

Answer

If the CSV option proves impossible, I would use a temporary table – and it would also speed up your query:

The helper_table will die as soon as you log off again.

Alternatively, use vsql with a script like this:

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement