I have a query that runs very quickly ~ 1 second. This query consists of couple of subqueries like:
select T.a,T.b,T.c from ( select from table 1 where ... left join table 2 on.. where.. left join table 3 on.. where.. ) as T
This query runs in parallel, I can see that in the query plan. But once I add some additional info using a join, the query becomes serial, and takes a lot more time to execute, for example:
select T.a,T.b,T.c, TT.d, TTT.e from ( select from table 1 where ... left join table 2 on.. where.. left join table 3 on.. where.. ) as T join TT on T.a = TT.a join TTT on TTT.d = TT.d
Please note that tables are joined chained one by one (I think this is important in my case). As subqueries take a lot longer to execute, I thought of removing joins and rewriting adding additional information using functions. Is there any better way to keep the query parallel, but still add additional info?