Thx for suggestions,
I do some modifications but TD still tries to make joins. Any ideas?
I created SRC table using:
create table SRC ( PART varchar(2) not null, ID varchar(3) not null, DATA float) primary index (PART, ID);
view:
Create view WIDE as
Select
a0.ID as ID,
a0.DATA as DATA0,
a1.DATA as DATA1,
a2.DATA as DATA2
from SRC a0
left join SRC a1
on a0.ID=a1.ID and a0.PART='00' and a1.PART='01'
left join SRC a2
on a0.ID=a2.ID and a0.PART='00' and a2.PART='02'
explain select id,data0 from wide;
*** Help information returned. 34 rows.
*** Total elapsed time was 1 second.
Explanation
---------------------------------------------------------------------------
1) First, we lock a distinct SAS."pseudo table" for read on a RowHash to prevent global deadlock for SAS.a0.
2) Next, we lock SAS.a0 in view wide for read.
3) We do an all-AMPs RETRIEVE step from SAS.a0 in view wide by way of an all-rows scan with no residual conditions into Spool 3 (all_amps), which is redistributed by the hash code of (SAS.a0.ID, '01') to all AMPs. Then we do a SORT to order Spool 3 by row hash. The size of Spool 3 is estimated with low confidence to be 2 rows (54 bytes). The estimated time for this step is 0.01 seconds.
4) We do an all-AMPs JOIN step from Spool 3 (Last Use) by way of a RowHash match scan, which is joined to SAS.a1 in view wide by way of a RowHash match scan with a condition of ("SAS.a1 in view wide.PART = '01'"). Spool 3 and SAS.a1 are left outer joined using a merge join, with condition(s) used for non-matching on left table ("PART = '00'"), with a join condition of ("ID = SAS.a1.ID"). The result goes into Spool 4 (all_amps), which is redistributed by the hash code of (SAS.a0.ID, '02') to all AMPs. Then we do a SORT to order Spool 4 by row hash. The size of Spool 4 is estimated with no confidence to be 2 rows (54 bytes). The estimated time for this step is 0.03 seconds.
5) We do an all-AMPs JOIN step from Spool 4 (Last Use) by way of a RowHash match scan, which is joined to SAS.a2 in view wide by way of a RowHash match scan with a condition of ("SAS.a2 in view wide.PART = '02'"). Spool 4 and SAS.a2 are left outer joined using a merge join, with condition(s) used for non-matching on left table ("PART = '00'"), with a join condition of ("ID = SAS.a2.ID"). The result goes into Spool 2 (group_amps), which is built locally on the AMPs. The size of Spool 2 is estimated with no confidence to be 3 rows (138 bytes). The estimated time for this step is 0.05 seconds.
6) Finally, we send out an END TRANSACTION step to all AMPs involved in processing the request.
-> The contents of Spool 2 are sent back to the user as the result of statement 1. The total estimated time is 0.09 seconds.
↧