We are using a query which uses union all in a program which fetches some millions of records. Since we are looking at CPU usage reduction, is there any alternative to the union all in the following scenario?
table 1 has a column say decide_table. and table 1 has two child tables table 2 and table 3. If decide_table has the value 'table 2', the child row is in table 2 and if it has the value 'table 3', the child row is in table 3.
Hence we are using a union all for table 2 and table 3 so that the row is fetched from the corresponding child table. Is there a better way of handling this scenario?