I have a SQL with multiple UNION as follows
select a,c from table1 ......
UNION
select a,c from table2 ......
UNION
select a,c from table3 ......
UNION
select a,c from table4 ......
Each of the SQL returns different number of rows, varying from 100 to 200,000
What I have seen is that when these SQL are executed separately, they return results in less than a minute.
But when UNION'ed like show above, they take upto few hours.
Is this because Oracle optimizer is trying to analyze ( in common language terms ) too much information and is not able to figure out best execution plan which fits every SQL ?