1. A computer-implemented method for minimizing a lock period to modify shared data in a shared database, the method comprising: executing one or more initial instances of a process without acquiring a lock on the shared database, the process comprising a plurality of instances with each instance being one of the initial instances or a final instance, each initial instance reading the shared data and generating a result that is at least partially stored in a buffer; determining that a next instance is the final instance of the process based on an estimated runtime of the next instance by determining whether the estimated runtime is acceptable as the lock period for modifying the shared data; and executing the final instance by using buffered results during execution and acquiring the lock on the shared database to modify the shared data.