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)
Sat, Dec 7, 10:35 PM
Unknown Object (File)
Nov 25 2024, 2:57 PM
Unknown Object (File)
Nov 25 2024, 2:57 PM
Unknown Object (File)
Nov 21 2024, 9:27 AM
Unknown Object (File)
Nov 21 2024, 9:27 AM
Unknown Object (File)
Nov 21 2024, 9:26 AM
Unknown Object (File)
Nov 21 2024, 9:25 AM
Unknown Object (File)
Oct 22 2024, 2:29 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