Optimize a Group By that is done on a joined table in Azure SQL Data Warehouse

93 Views Asked by At

I've been working at optimizing a query that I've been given, I'm curious if there is any way to speed up the following query that I have.

This isn't the exact query that I am using but I think it serves to show what I am working with.

(I'm using a data warehouse for the following)

SELECT sum(a), b, c, d FROM
(

SELECT a, tb.b, tc.c, td.d FROM table_a ta
LEFT JOIN table_b tb on ta.g = tb.g
LEFT JOIN table_c tc on ta.f = tc.f
LEFT JOIN table_d td on ta.e = td.e 

) as table

GROUP BY b, c, d

I have the inner query quite optimized so I don't think there is any issue there, the problem is when I attempt a group by on these values it slows down quite significantly, I'm pretty sure the query is having trouble distributing the work on the group by clause since nothing is indexed within the sub query.

Any suggestions?

execution plan

0

There are 0 best solutions below