Unanswered: SQL problem: optimizing UNION operator
My application's search is based on some queries grouped through union or intersect operator.
My problem is that I would like to optimize the search and I cannot optimize UNION or INTERSECT operator.
If I add the times of all the queries I get a number infinitely small than the time obtain by the reunion or intersection of these queries.
For example, if I have:
If I add the select1, 2, 3 etc. response time I will get a very small result comparing with the union (Intersect) result time. I cannot use union all because I need to eliminate the duplicates.
Can you give me an advice regarding this optimizing problem?
Thanks in advanced.
Removal of duplicates could be taking sometime but may not be taking so long. Why don't you check the individual access path and the combined access path using EXPLAIN? It might give some clue. Besides the volume of data being handled could have some information.