'Cannot launch UNION all query to more than 4 tables when using ssh

I'm trying to launch a query like:

(Select * from table1)
UNION ALL
(Select * from table2)
UNION ALL
(Select * from table3)
UNION ALL
(Select * from table4)
UNION ALL
(Select * from table5);

It doesn't work and remains on hold for hours without any error message, but If I select just four tables it works.

I launch it on a remote server while having a ssh tunnel to a third host activated, the problem is that on the last days we have changed VPN between the second and third host and it's not longer working. Moreover, the query per se works when it's launched directly on the third server without ssh tunnel and it takes 0,05s.

Any ideas why this is happening?



Solution 1:[1]

Maybe there is an issue with your table5 query. Have your tried just querying that one without the UNION?

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Kathi Kellenberger