title: Simple MySQL INSERT query very slow
body: <p>I think I'm having an issue with my MySQL server or the Query I'm using. I'm not sure which.</p>
  
  <p>Server is VM Ubuntu12.4 4 cores/16gb Ram
  MySQL 5.5.24 x86</p>
  
  <p>My query: </p>
  
  <pre><code>INSERT INTO `NEWTEXT`.`Order_LineDetails`
  
  ( OrderLineItem_ID, Customer_ID, Order_ID, ProductName )
  SELECT
  'Order_Details'.'OrderDetailID',
  'Orders'.'CustomerID',
  'Order_Details'.'OrderID',
  'prods'.'ProductName'
  
  FROM Order_Details 
  JOIN Orders ON Orders.OrderID = Order_Details.OrderID
  JOIN Products prods ON prods.ProductID = Order_Details.ProductID
  WHERE Orders.OrderID = 500000
  </code></pre>
  
  <p>I'm not really sure where to start looking for the problem. The above query takes 9+ seconds to complete. The Order_Details table contains 1,800,000+ records in it.</p>
  
  <p>The thing that is bugging me on this is that when I run a select query it also goes slow.  BUT, I have another server that's running win2k MsSql and its almost instant with the same SELECT query.</p>
  
  <p>I'm hoping someone could point me in the right direction here.</p>
  
  <h2>EDIT</h2>
  
  <p>Well, sorry for the troubles and thanks for your help.</p>
  
  <p>I found that the problem was that after I finished the import I skipped the step where I would normally assign the new tables a <code>PrimaryKey</code>. I know, :( dumb.</p>
  
  <p>Anyway! Don't forget to assign your <code>Primary Keys</code>!</p>