in reply to calculate run time

The easiest way to handle this sort of thing is to set an alarm before you call the database. That way, you can detect the alarm, and perform some action should the database action fail.

One way to achieve this would be as follows:

local $SIG{ALRM} = sub { die "Database error!\n"; }; alarm 60; # wait 60 seconds before interrupting # call to database

Hope that helps ..
--Foxcub