0

Continuation of questions, 1, 2

I have a MySQL table with large number of rows. I am fetching all rows through JDBC and doing some manipulation with them which is unavoidable. I want to update a flag on the MySQL table telling that the operation is done. My dilemma is :

  1. I am fetching all these rows, so at that time itself should I update the flag ?

    Benefit

    1. Time and performance will improve- You don't have to go for another round of MySQL operation, function call etc.

    Problems

    1. The task which I want to do with this data is not completed at this point of time. So, setting the flag is not really right.

    2. The method to do selection should ideally do just selection option according to software engineering principles.

  2. Later, once my tasks are done, I should call another method exclusively written for update operation?

    Benefit:

    1. More aligned to software engineering principles.

    Problem:

    1. It will take may be close to double amount of time to do this- Overhead of another method call, JDBC call, Updating a million rows!

Experienced folks, could you please help me.

Thanks

Community
  • 1
  • 1
pnv
  • 1,437
  • 3
  • 23
  • 52

1 Answers1

1

This seems more like a batch job. You can set a timer for executing batch job of updating the flags (In your terms complete operation). Then you do not have to do those operations from the JDBC client.

pd30
  • 240
  • 1
  • 7