Thursday, July 16, 2020

Update millions of rows in very huge table Performance


/*Use set value also in where clause.
Eg. Set nUsablePledgestock=1
Where nUsablePledgestock !=0
"/

Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where nUsablepledgestock!=Quantity ;
Commit ;


/* split the query to month-wise */
Following will not increase undo in very high amount.

set timing on
spool d:\poaupdate.txt
Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran <='01-APR-2019' and nUsablepledgestock!=Quantity; 
Commit ;

Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-APR-2019' and dtoftran <='01-MAY-2019' and nUsablepledgestock!=Quantity; 
Commit ;

Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-MAY-2019' and dtoftran <='01-JUN-2019' and nUsablepledgestock!=Quantity; 
Commit ;

Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-JUN-2019' and dtoftran <='01-JUL-2019' and nUsablepledgestock!=Quantity; 
Commit ;


Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-JUL-2019' and dtoftran <='01-AUG-2019' and nUsablepledgestock!=Quantity; 
Commit ;


Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-AUG-2019' and dtoftran <='01-SEP-2019' and nUsablepledgestock!=Quantity; 
Commit ;

Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-SEP-2019' and dtoftran <='01-OCT-2019' and nUsablepledgestock!=Quantity; 
Commit ;

Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-OCT-2019' and dtoftran <='01-NOV-2019' and nUsablepledgestock!=Quantity; 
Commit ;

Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-NOV-2019' and dtoftran <='01-DEC-2019' and nUsablepledgestock!=Quantity; 
Commit ;

Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-DEC-2019' and dtoftran <='01-JAN-2020' and nUsablepledgestock!=Quantity; 
Commit ;


Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-JAN-2020' and dtoftran <='01-FEB-2020' and nUsablepledgestock!=Quantity; 
Commit ;


Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-FEB-2020' and dtoftran <='01-MAR-2020' and nUsablepledgestock!=Quantity; 
Commit ;

Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-MAR-2020' and dtoftran <='01-APR-2020' and nUsablepledgestock!=Quantity; 
Commit ;

Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-APR-2020' and dtoftran <='01-MAY-2020' and nUsablepledgestock!=Quantity; 
Commit ;


Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-MAY-2020' and dtoftran <='01-JUN-2020' and nUsablepledgestock!=Quantity; 
Commit ;

Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-JUN-2020' and dtoftran <='01-JUL-2020' and nUsablepledgestock!=Quantity; 
Commit ;


Update PowerofAttorneystocks set nUsablePledgestock=Quantity Where firmnumber='CUB-000001' and dtoftran >'01-JUL-2020' and nUsablepledgestock!=Quantity; 
Commit ;

...
....
...
.....
....


spool off

No comments:

Post a Comment

Followers