for d in c loop; insert; commit ...

  • From: stv <stvsmth@xxxxxxxxx>
  • To: oracle-l@xxxxxxxxxxxxx
  • Date: Wed, 15 Aug 2007 16:11:48 -0600

Why in the world did I inherit a database with all this nonsense everywhere ...

        lc := 0;
        For d in C loop
                lc := lc + 1;
                # insert stuff
                if mod(lc, 50) = 0 then commit; end if;
        end loop;
        commit;

Any ideas on what problem the previous folks were attempting to get around?

I've read over Tom Kyte's explanation of why this is silly in Export
Oracle Database Architecture (Ch 9, What does Commit do?) ... and he's
got me convinced, so convinced that I cannot fathom why anyone would
do this in the first place. I'm guessing it's common tendency, given
the time Kyte spent in debunking the myth. I seem to remember redo
logs, size & speed, being related to this hack, but I cannot find that
reference ...

When I transitioned into the job I saw this loop non-sense and asked
why ... the developer said they would have to wait for a long time
without these statements. He seemed bright enough on most other
things, so I let it slide for the moment (having just read Kyte's book
the previous month). Now that I'm digging into code, I cannot fathom
why that would be ...

I'm not an Oracle whiz by any stretch, but this has Bad Smell written
all over it ...

--Steve Smith
--
//www.freelists.org/webpage/oracle-l


Other related posts: