MySQL empty DB after Krypton Update

I have figured out the problem. The first time I ran this upgrade, I lost the HDMI connection and rebooted the machine via ssh after several minutes. It looks like that stopped the database migration mid-way, because…

I am running the same upgrade again on a different install and the database migration is taking OVER 30 MINUTES!

This happened last time I did a major version upgrade. This database query is taking AGES to run. Last time this happened, months (years?) ago, I posted a simple fix to add an index to the database that would make this migration run in SECONDS.

-- Connection Id: 756
-- User: raspbmc
-- Host: 192.x.x.x:50708
-- DB: MyVideos107
-- Command: Query
-- Time: 1922
-- State: Copying to tmp table
SELECT episode.idShow, MAX(episode.c09) FROM episode LEFT JOIN streamdetails ON streamdetails.idFile = episode.idFile AND streamdetails.iStreamType = 0 WHERE episode.c09 <> streamdetails.iVideoDuration OR streamdetails.iVideoDuration IS NULL GROUP BY episode.idShow

Think of the person who was too lazy to understand/add the index to the database. How many kodi users are there? A thousand? Tens of thousands? A million? That person has wasted that many times (as I type this the query is still running and has taken) 36 minutes so far… of human lives!