Monday, December 21, 2009

BULK UPDATE using FORALL in Oracle PLSQL - Awesome experience..

In one of the projects I work, there arose a need to conditionally update a few column values of a table. How many rows did we need to update ? Roughly 5 million rows out of 252 million total rows.

Experimented many approaches to get this done. Some of them ....
1. Use a single UPDATE statement (Worst thing to ever do for huge data updates)
2. Update in lots of 50K - using plain update statement (Kind of OK, though it handled shorter commits, I wasnt happy with performance)
3. Fantastic result : When I used PLSQL(bulk update using FORALL), I realized I had been under utilizing PLSQL for my day to day jobs. No doubt... Oracle PLSQL rocks.