I found a problem with my application which only occurs under high loads (isn't that always the case?). snippets of perl... insert into tokens (token) select values.token from (values TOKEN_LIST_STRING) as values(token) left outer join tokens t using (token) where t.token_idx is null $sql =~ s/TOKEN_LIST_STRING/$string/ where $string is of the form (('one'),('two')) This works 99% of the time. But everyone once in a long while it seems that I hit simultaneaous execute() statements that deadlock on the insertion. Right now I know of no other way to handle this than to eval{ } the execution and if it fails, sleep random milliseconds and retry... "wash rinse repeat" for some number of times. Is there any better way of doing this or some other means to manage DEADLOCK?