I am running a proc sql in teradata and this is taking more than 1 hour to run. The data size is relatively small with about 86,000 rows returned. I create a temp teradata table from a sas dataset with this code:
libname TDWORK teradata user="&user.@LDAP" password=&pword tdpid=bmg dbmstemp=yes connection=global tpt=No ;
data tdwork.Cust_Mstr_Wk_Curr(dbcommit=20000 multistmt=yes dbcreate_table_opts='PRIMARY INDEX (Cust_Num)') ; set Cust_Mstr_Wk_Curr_Cdb ; run;
I then need to join this temp table to other tables in teradata with this code.
libname bmg_pdd teradata server=<servername> tdpid=bmg database="Bmgpdd" connection=global mode=teradata user="&user.@LDAP" password = &pword; options symbolgen macrogen;
proc sql ; create table tdwork.Bmgpdd_Acct_X_Cust_Hg as (Select A.* , M.Acct_Num As Acct_Num , M.Co_Id As Co_Id , B.Cust_Acct_Rel_Cd , m.Short_Name , m.PCode , m.Open_Dt , m.Reopen_Dt , m.Eom_Bal From tdwork.Cust_Mstr_Wk_Curr A, bmg_pdd.Acct_X_Cust_Hg_&yearmon._Cdb B, bmg_pdd.Acct_Mstr_&yearmon._Hg M Where A.Cust_Num = B.Cust_Num and B.Acct_Num = M.Acct_Num ); quit;
This code is within a macro. Given below is the log for this step.
MACROGEN(LAST12): proc sql ; SYMBOLGEN: Macro variable YEARMON resolves to 202302 SYMBOLGEN: Macro variable YEARMON resolves to 202302 MACROGEN(LAST12): create table tdwork.Bmgpdd_Acct_X_Cust_Hg as (Select A.* , M.Acct_Num As Acct_Num , M.Co_Id As Co_Id , B.Cust_Acct_Rel_Cd , m.Short_Name , m.PCode , m.Open_Dt , m.Reopen_Dt , m.Eom_Bal From tdwork.Cust_Mstr_Wk_Curr A, bmg_pdd.Acct_X_Cust_Hg_202302_Cdb B, bmg_pdd.Acct_Mstr_202302_Hg M Where A.Cust_Num = B.Cust_Num and B.Acct_Num = M.Acct_Num ); NOTE: SAS variable labels, formats, and lengths are not written to DBMS tables. NOTE: Table TDWORK.Bmgpdd_Acct_X_Cust_Hg created, with 85880 rows and 15 columns. MACROGEN(LAST12): quit; NOTE: PROCEDURE SQL used (Total process time): real time 1:08:08.17 cpu time 2:13.59
Is there a way to speed up the query? Thanks in advance.
... View more