0

Here's two pretty simple mysql statements (that happen in this order). For some reason, the second transaction often deadlocks. Does anyone have any idea why?

$query = "
        DELETE FROM queues
        WHERE   queuetype='autoresponder'
        AND recipient={$subscriberid}
    ";
    $this->Db->Query($query);

    $query = "
        INSERT INTO queues (queueid, queuetype, ownerid, recipient, processed)

        SELECT  queueid, 'autoresponder', ownerid, {$subscriberid}, 0
        FROM    autoresponders
        WHERE   listid={$listid}
        AND active<>0
    ";
    $status = $this->Db->Query($query);

Both tables have numerous indexes... enter image description here Does anyone have any idea why, when the two transactions are executed separately, the deadlock occurs on the second Query()?

For reference, here's the select explained...enter image description here

JoshGeake
  • 141
  • 3
  • 13

0 Answers0