title: MySql update query extremely slow
body: <p>I have a large Invoices table, and a second Locations table, that's not as big. I'm trying to add location's ids to their respective invoices, however the process is yet to finish, it's been running for an hour so far.
  My query looks as follows:</p>
  
  <pre><code>UPDATE Invoices
  INNER JOIN temp ON temp.invoice_number = Invoices.Invoice_Number AND Invoices.Invoice_Date &gt;= '2018-01-01'
  SET Invoices.fk_Locations = temp.location_id
  </code></pre>
  
  <p>In plain English it's taking my Invoices table (2018 only), and inner joins Temp table based on the matching invoice numbers, then updated fk_Locations (from Invoices) to be equal to location_id (from Temp.)</p>
  
  <p>1) There's 208K invoices as of 2018-01-01</p>
  
  <p>2) There's 61K invoices in the temp table, that I'm trying to merge.</p>
  
  <p>Running a basic SELECT instead of SET took only about 5 to 10 seconds. How do I make this query efficient?</p>