Page MenuHomePhabricator

[keyserver] Improve fetchKnownUserInfos query performance
ClosedPublic

Authored by ashoat on Jul 14 2023, 12:50 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jun 30, 11:02 AM
Unknown Object (File)
Mon, Jun 24, 5:02 AM
Unknown Object (File)
Wed, Jun 19, 6:45 PM
Unknown Object (File)
Wed, Jun 19, 6:45 PM
Unknown Object (File)
Wed, Jun 19, 6:45 PM
Unknown Object (File)
Sun, Jun 16, 7:17 AM
Unknown Object (File)
Fri, Jun 14, 6:54 AM
Unknown Object (File)
Mon, Jun 10, 7:23 PM
Subscribers
None

Details

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
  1. 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.
  2. Next, I tested this code change in my local environment. I tested loading the web app and creating a sidebar.
  3. 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).

Diff Detail

Repository
rCOMM Comm
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Harbormaster returned this revision to the author for changes because remote builds failed.Jul 14 2023, 12:56 PM
Harbormaster failed remote builds in B20934: Diff 28688!
tomek added inline comments.
keyserver/src/fetchers/user-fetchers.js
157–187 ↗(On Diff #28688)

Is it possible that a single row will have both user1_upload_id and user2_upload_id set?

This revision is now accepted and ready to land.Jul 17 2023, 3:49 AM
keyserver/src/fetchers/user-fetchers.js
157–187 ↗(On Diff #28688)

No, that shouldn't be possible. Either user1 or user2 should be the viewer (based on the WHERE clause), and the joins for up1 and up2 both attempt to exclude the viewer