Can we see the union you wrote- it may be the union itself that's killing you. Can you try creating an extract of this union? It will allow us to see if its the union or something else in tableau causing the issue. The extract will put it in the fastest form for Tableau to read it on the backend. You may be able to get out of this my simply pivoting your data within tableau which saves the custom sql portion of the slowdown. How many products do you have -this really should not be a performance issue however.
Further I have no clue what the circle/pie chart desire is and what you want to do with that. So lets fix the speed issue first.
Thanks for the reply. I have tried creating an extract.
1. I have 9 products.
2. I have 50k plus customers.
When you combine the two, the union query makes a 50k excel file turn into 1 million rows
Below is a screenshot of my query: