1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-18 21:02:41 +01:00
phorge-phorge/resources/sql/patches
epriestley 431c57688e Improve performance of project list view
Summary:
D477 added functionality to the project list view but had a couple of
performance issues that I missed in review, because it took the query count for
the page from around 3 to as many as 300, including up to 100 heavyweight search
index queries.

This fixes the two simple N+1 query problems. This general pattern of data
access often occurs:

  COUNTEREXAMPLE
  $cats = load_cats();
  foreach ($cats as $cat) {
    $cats_hats = load_hats_for_cat($cat);
    // ...
  }

But this issues "N+1" queries, i.e. if you load 100 cats you issue 101 queries.
It is faster to group the queries instead:

  $cats = load_cats();
  $hats = load_all_hats_for_these_cats($cats);
  foreach ($cats as $cat) {
    $cats_hats = $hats[$cat->getID()];
  }

MySQL can execute one query which returns all the results much faster than 100
queries which return one result, especially if the database is not local (i.e.,
over the network).

However, this doesn't save a ton of time. The bigger issue is that I didn't have
the right keys on the relationship tables in the search engine. This adds them,
and reduces the search engine lookup cost from 25-80ms (for
secure.phabricator.com) down to 1-3ms.

I still probably want to get this out of the loop at some point but it's okay
for now and the page loads in a few ms rather than taking more than a second.

Test Plan:
Used "services" tab, "xhprof" and "EXPLAIN" to analyze page performance. I
measured these changes:

  - Query count: 1 + (3 * N projects) -> 3 + (N projects) (e.g., 301 -> 103)
  - Total time spent querying, ignoring search indexes: 40ms (local.aprhont.com)
-> 20ms (local.aphront.com)
  - Cost for search index query: 25-80ms (secure.phabricator.com) -> 1-3ms

Reviewed By: cadamo
Reviewers: cadamo, aran, jungejason, tuomaspelkonen
CC: aran, cadamo, epriestley
Differential Revision: 485
2011-06-21 14:43:15 -07:00
..
000.project.sql Task -> Project assocation, file uploads 2011-02-20 20:08:53 -08:00
001.maniphest_projects.sql Fully-qualify this SQL patchfile. 2011-02-20 20:10:07 -08:00
002.oauth.sql Github OAuth 2011-02-21 00:23:24 -08:00
003.more_oauth.sql Store OAuth tokens and more OAuth account info. 2011-02-22 10:27:27 -08:00
004.daemonrepos.sql Rough cut of repository tracking 2011-03-06 22:29:22 -08:00
005.workers.sql Rough cut of Workers 2011-03-10 13:48:29 -08:00
006.repository.sql durf durf sql 2011-03-15 20:51:53 +00:00
007.daemonlog.sql Diffusion/phd/console improvements. 2011-03-15 13:38:14 -07:00
008.repoopt.sql Fix various parsing bugs in Differential. 2011-03-19 14:42:17 -07:00
009.repo_summary.sql Sorta need this file. 2011-03-20 17:55:31 -07:00
010.herald.sql Rough cut of Herald home controller. 2011-03-22 13:50:08 -07:00
011.badcommit.sql Derp derp, apparentl neglected to save this file. 2011-03-26 23:59:29 -07:00
012.dropphidtype.sql Removed "PHID Types" storage object and interface components 2011-03-31 14:01:13 -07:00
013.commitdetail.sql More Diffusion junk. 2011-03-30 22:08:41 -07:00
014.shortcuts.sql Restore "Shortcuts" feature to Diffusion. 2011-03-31 00:33:44 -07:00
015.preferences.sql User preferences ported from tools 2011-03-31 13:44:20 -07:00
016.userrealnameindex.sql Add basic detail-parser functionality. 2011-04-01 17:11:55 -07:00
017.sessionkeys.sql Optimize session query for nontrivial number of user accounts. 2011-04-02 16:39:40 -07:00
018.owners.sql Some owners write workflows. 2011-04-03 22:03:27 -07:00
019.arcprojects.sql Sync up UUIDs and create project configs. 2011-04-05 21:55:04 -07:00
020.pathcapital.sql Fix field capitalization. 2011-04-05 22:30:10 -07:00
021.xhpastview.sql xhpastview 2011-04-06 22:43:56 -07:00
022.differentialcommit.sql Close the loop on Diffusion commits posting back to Differential. 2011-04-07 21:59:42 -07:00
023.dxkeys.sql Turns out MySQL tables need keys. Who knew?! 2011-04-09 22:19:10 -07:00
024.mlistkeys.sql Properly support mailing lists, with actual testing! 2011-04-10 10:16:14 -07:00
025.commentopt.sql Lint and unit star support. 2011-04-10 17:19:01 -07:00
026.diffpropkey.sql Missing key for large datasizes. 2011-04-10 17:25:24 -07:00
027.metamtakeys.sql Add some metamta keys. 2011-04-12 18:19:24 -07:00
028.systemagent.sql Very basic system agent support. 2011-04-12 18:19:25 -07:00
029.cursors.sql Avoid Timeline race condition 2011-04-14 10:12:10 -07:00
030.imagemacro.sql Image macros for Phabricator! 2011-04-13 20:08:13 -07:00
031.workerrace.sql Prevent a race in Phabricator workers 2011-04-14 12:09:56 -07:00
032.viewtime.sql Differential Updates View 2011-04-28 14:40:41 -07:00
033.privtest.sql Improve schema upgrade workflow for unprivileged users 2011-04-30 00:50:48 -07:00
034.savedheader.sql Make X-Herald-Rules header sticky 2011-05-03 06:06:57 -07:00
035.proxyimage.sql Restore image proxying to Remarkup 2011-05-03 18:49:06 -07:00
036.mailkey.sql Support email replies in Phabricator 2011-05-05 14:58:57 -07:00
037.setuptest.sql Add a "setup" mode which guides new users through application configuration 2011-05-10 15:12:30 -07:00
038.admin.sql Admin and disabled flags for users 2011-05-12 11:17:50 -07:00
039.userlog.sql Provide an activity log for login and administrative actions 2011-05-20 19:08:26 -07:00
040.transform.sql Basic image thumbnailing 2011-05-27 09:33:33 -07:00
041.heraldrepetition.sql herald: add the ability to execute a rule the first time only 2011-06-09 10:35:37 -07:00
042.commentmetadata.sql Store metadata with Differential and Maniphest comments, and store added 2011-06-09 10:43:25 -07:00
043.pastebin.sql Pastebin 2011-06-10 13:41:18 -04:00
044.countdown.sql Countdown tweaks 2011-06-13 18:53:43 -07:00
045.timezone.sql Provide a default non-NULL timezone in the PhabricatorUser class 2011-06-20 13:13:51 -07:00
046.conduittoken.sql Fix syntax clowning in patch 046. 2011-06-20 05:59:42 -07:00
047.projectstatus.sql Project list and profile view modifications 2011-06-20 16:13:44 -03:00
048.relationshipkeys.sql Improve performance of project list view 2011-06-21 14:43:15 -07:00