Yeah the script was intended as a proof of concept alpha version software, not written by me. And the guy who wrote it inherited the design from someone else who figured that stored procedures were the best thing ever so the stored procedures were already written.
So it's a hack of a hack of an alpha release.. and of course we have over 10,000 users globally on the thing now.
Good thing I spent a week sifting through the stored procedures optimizing them, otherwise we'd be offline right now. They were truly horrible.. I think 80% of the queries were requiring a full table scan, and taking dozens to hundreds of seconds to complete.. now only 5% of queries take more than 1 second
Still, hoping to get on top of all the changes and fixes so I can write a big test suite so I can then rewrite the whole thing in PHP.