I have a query in MySQL from 4 tables. When I run these queries individually they run quick within 1 second.
But when I combine them using
UNION ALL, machine comes under heavy load and take at least 10 seconds for the same query in
UNION ALL. And I have digged whole the internet including YouTube, but unfortunately I did not find any solution yet.
SELECT * FROM ( SELECT id, sessionId FROM promotion UNION ALL SELECT id, sessionId FROM transport_details UNION ALL SELECT id, sessionId FROM fee_details ) a;
Thank you all the developers here who participated in my question.
Although I did not find any satisfactory resolution of MySQL
UNION ALL slow query. But I have managed it up to 80% by optimizing MySQL individual queries.
Also there is a provision to increase the memory and CPU limits.
Answered By – kk4You
Answer Checked By – Cary Denson (BugsFixing Admin)