I have four tables with the below query. select query is taking long time to query
table1(221 crore records),
table2(230 crore records),
table3(214 crore records),
table4(90 lakh records),
Could you please suggest some steps to improve the performance of the query as its taking 40 hours to load data into staging_table…Thanks.
select
column1, column2,...... ...column50 into acct_tl_new
from table1(221 crore records) t1
inner join table2 t2 on t1.accid=t2.accid
left join table3 t3 on t3.accid=t3.accid
left join table4 t4 on t1.pr_no=t4.pr_no and t1.clientid=t4.clientid
where t3.rn=1 or t2.accid is null
insert into staging_table
SELECT clientid, accid, accno, acctyp from acct_tl_new
where clientid in (101, 102, 104,105,109) and acctype='5'
alter table acct_tl_new rebuild partitition =ALL with (DATA_COMPRESSION = PAGE)
New contributor