
The main problem is that we were using an index on fdroid_apk.vercode, when it should have been using an index on fdroid_apk.appId. There are thousands of apks which would match based on vercode, but only two or three which match based on appId. This improves performance of the calculate-suggested-vercode query from 25,000ms to 100ms.