title: MySql - Updating a table with 1,000 rows is taking 30 seconds
body: <p>I have a table with a 1000 rows in. I'm using a cursor to select each row in a loop, and update a value on each row. The table has a single primary key, and no indexes. The select and update statement are simply using the primary key ID. The operation to update all 1,000 rows is taking exactly 31 seconds with no database load. When I have a few things running over the DB, this goes up to 80+ seconds.</p>
  
  <p>Can someone explain to me why with absolutely no load on the DB, 1,000 rows is taking 30+ seconds to execute?</p>
  
  <p>Thanks.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>DECLARE curPlayers CURSOR FOR
      SELECT
          Id,
          Turns,
          Money,
          Morale,
          MissilePower,
          TurnsPerUpdate,
          MoneyPerUpdate,
          MoralePerUpdate,
          MissilePowerPerUpdate,
          AvailableLandToPurchase,
          TS
      FROM player;
  
  OPEN curPlayers;
  
  FETCH curPlayers INTO
              vPlayerId,
              vPlayerTurns,
              vPlayerMoney,
              vPlayerMorale,
              vPlayerMissilePower,
              vPlayerTurnsPerUpdate,
              vPlayerMoneyPerUpdate,
              vPlayerMoralePerUpdate,
              vPlayerMissilePowerPerUpdate,
              vPlayerAvailableLandToPurchase,
              vPlayerTS;
  
  -- ...Some simple sets on the vNewTurns variables used below...
  
  UPDATE player SET
              Turns = vNewTurns,
              Money = vNewMoney,
              Morale = vNewMorale,
              MissilePower = vNewMissilePower,
              AvailableLandToPurchase = vNewAvailableLandToPurchase
          WHERE
              Id = vPlayerId;
  </code></pre>