java - Is it good to delete when reading ( adding each statement to delete ) and doing a batch delete at the end or do a single delete? -
archive , delete process. 1 recommended?
this process runs end of day when window closed extraneous transactions other 1 disallow interference below tx.
i. batch delete
object = read() while ( hasnext() ) { object = next(); call archive_process archive object. add delete. } batch_delete. ii. single delete statement.
object = read() while ( hasnext() ) { object = next(); call archive_process archive object. } use same sql above, instead delete in single statement. which 1 recommended?
it depends on specific needs:
- if code require every record deleted can perform other tasks, deleting 1 row @ time on each loop may needed.
- if code can tasks independently of wether record deleted or not, deleting @ end (on single batch) better.
you need remember every delete triggers action on data, , may have impact on disk read-write speed of program. single batch delete may have positive impact on speed of code compared many one-row delete operations.
Comments
Post a Comment