if PHP is timing out, you can do this:
set_time_limit (0)
which says 'ignore the default time limit for scripts and let this script run indefinitely'. it won't work if your server is in safe mode. i'm not sure but there might be other possible server config options which would prevent it from working.
if your DB is too busy, i'm not sure what to say. there are threads in this forum that discuss 'too many connections' problems. try searching for those.
OR, your database might benefit from adding some indexing. certain queries can be speeded up quite dramatically by indexing a table. if you are searching for records based on the values in a particular field, try adding an index on that field. primary keys, first name/last name, city, state, country, etc.