title: MySQL very slow loop
body: <p>I made a very simple procedure (a while loop) in MySQL:</p>
  
  <pre><code>BEGIN
  
      DECLARE start INT;
      DECLARE ending INT;
  
      SET start = 1;
      SET ending = 4000000;
  
      WHILE (start &lt;= ending) DO
          SET start = start + 1;
      END WHILE;
  END
  </code></pre>
  
  <p>This takes ~26 seconds on a dual core machine (each core on 100%) and I don't understand why.</p>
  
  <p>Could you give me an answer?</p>