I am using an SDK to call restful web services which comunicate with a gateway. On test env the gateway is quite slow. Occasionally I get 'java.sql.SQLException: Lock wait timeout exceeded; try restarting transaction' when waiting for the response. I am wondering if it is a good idea to optimize the code to wait for some more or just leave it as it is?