@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve Differential query plans

Summary:
Ref T8575. We run a big "(A) UNION (B)" query on the home page and on the main Differential page.

"A" can always be improved by using `%Ls`, so it can use the second half of the `(authorPHID, status)` key.

"B" can sometimes be improved if the fraction of open revisions is smaller than the fraction of revisions you are reviewing. This is true for me on secure.phabricator.com (I'm a reviewer, either directly or via 'Blessed Reviewers', on about 80% of revisions, but <5% are open). In these cases, a `(status, phid)` key is more efficient.

Test Plan: Tweaked queries and added keys on this server, saw less derpy query plans and performance.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T8575

Differential Revision: https://secure.phabricator.com/D13325

+18 -6
+10 -6
src/applications/differential/query/DifferentialRevisionQuery.php
··· 771 771 $this->updatedEpochMax); 772 772 } 773 773 774 + // NOTE: Although the status constants are integers in PHP, the column is a 775 + // string column in MySQL, and MySQL won't use keys on string columns if 776 + // you put integers in the query. 777 + 774 778 switch ($this->status) { 775 779 case self::STATUS_ANY: 776 780 break; 777 781 case self::STATUS_OPEN: 778 782 $where[] = qsprintf( 779 783 $conn_r, 780 - 'r.status IN (%Ld)', 784 + 'r.status IN (%Ls)', 781 785 DifferentialRevisionStatus::getOpenStatuses()); 782 786 break; 783 787 case self::STATUS_NEEDS_REVIEW: 784 788 $where[] = qsprintf( 785 789 $conn_r, 786 - 'r.status IN (%Ld)', 790 + 'r.status IN (%Ls)', 787 791 array( 788 792 ArcanistDifferentialRevisionStatus::NEEDS_REVIEW, 789 793 )); ··· 791 795 case self::STATUS_NEEDS_REVISION: 792 796 $where[] = qsprintf( 793 797 $conn_r, 794 - 'r.status IN (%Ld)', 798 + 'r.status IN (%Ls)', 795 799 array( 796 800 ArcanistDifferentialRevisionStatus::NEEDS_REVISION, 797 801 )); ··· 799 803 case self::STATUS_ACCEPTED: 800 804 $where[] = qsprintf( 801 805 $conn_r, 802 - 'r.status IN (%Ld)', 806 + 'r.status IN (%Ls)', 803 807 array( 804 808 ArcanistDifferentialRevisionStatus::ACCEPTED, 805 809 )); ··· 807 811 case self::STATUS_CLOSED: 808 812 $where[] = qsprintf( 809 813 $conn_r, 810 - 'r.status IN (%Ld)', 814 + 'r.status IN (%Ls)', 811 815 DifferentialRevisionStatus::getClosedStatuses()); 812 816 break; 813 817 case self::STATUS_ABANDONED: 814 818 $where[] = qsprintf( 815 819 $conn_r, 816 - 'r.status IN (%Ld)', 820 + 'r.status IN (%Ls)', 817 821 array( 818 822 ArcanistDifferentialRevisionStatus::ABANDONED, 819 823 ));
+8
src/applications/differential/storage/DifferentialRevision.php
··· 102 102 'repositoryPHID' => array( 103 103 'columns' => array('repositoryPHID'), 104 104 ), 105 + // If you (or a project you are a member of) is reviewing a significant 106 + // fraction of the revisions on an install, the result set of open 107 + // revisions may be smaller than the result set of revisions where you 108 + // are a reviewer. In these cases, this key is better than keys on the 109 + // edge table. 110 + 'key_status' => array( 111 + 'columns' => array('status', 'phid'), 112 + ), 105 113 ), 106 114 ) + parent::getConfiguration(); 107 115 }