[keyserver] Improve fetchKnownUserInfos query performance
Summary:
Most of the context is in ENG-3878:
I've identified a query that returns the same information, but has significantly better performance.
Following my earlier observation that the OR clause in the uploads join is responsible for the majority of the cost, I split that join up into two joins.
Test Plan:
- First, I compared how long the query took on my keyserver MariaDB in production. I found it sped the query up from ~3.1s to ~0.4s.
- Next, I tested this code change in my local environment. I tested loading the web app and creating a sidebar.
- Finally, I deployed this code change to my keyserver in production, and found that it improved the performance in some cases, and made it possible for me to create sidebars again (albeit after one retry).
Reviewers: tomek, atul
Reviewed By: tomek
Differential Revision: https://phab.comm.dev/D8499