mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-18 19:40:55 +01:00
No description
72dec7cd25
Summary: The old query was effectively SELECT DISTINCT revision.* FROM `differential_revision` revision JOIN `differential_relationship` relationship ON (relationship.revisionID = revision.id AND relationship.objectPHID in ('PHID-USER-a113b9ae4ee9524d0a20')) OR revision.authorPHID = 'PHID-USER-a113b9ae4ee9524d0a20' LEFT JOIN `differential_viewtime` viewtime ON viewtime.viewerPHID in ('PHID-USER-a113b9ae4ee9524d0a20') AND viewtime.objectPHID = revision.phid AND GREATEST(1304022277, IFNULL(viewtime.viewTime, 0)) < revision.dateModified ORDER BY dateModified DESC; I'm not a db performance expert but it looks like the problem is that we have to scan all revisions mysql> EXPLAIN SELECT DISTINCT revision.* FROM `differential_revision` revision JOIN `differential_relationship` relationship ON (relationship.revisionID = revision.id AND relationship.objectPHID in ('PHID-USER-a113b9ae4ee9524d0a20')) OR revision.authorPHID = 'PHID-USER-a113b9ae4ee9524d0a20' LEFT JOIN `differential_viewtime` viewtime ON viewtime.viewerPHID in ('PHID-USER-a113b9ae4ee9524d0a20') AND viewtime.objectPHID = revision.phid AND GREATEST(1304022277, IFNULL(viewtime.viewTime, 0)) < revision.dateModified ORDER BY dateModified DESC; +----+-------------+--------------+-------+--------------------+------------+---------+-------+--------+------------------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+-------------+--------------+-------+--------------------+------------+---------+-------+--------+------------------------------------+ | 1 | SIMPLE | revision | ALL | PRIMARY,authorPHID | NULL | NULL | NULL | 254127 | Using temporary; Using filesort | | 1 | SIMPLE | viewtime | ref | PRIMARY | PRIMARY | 66 | const | 17 | Distinct | | 1 | SIMPLE | relationship | index | PRIMARY,objectPHID | objectPHID | 72 | NULL | 966900 | Using where; Using index; Distinct | +----+-------------+--------------+-------+--------------------+------------+---------+-------+--------+------------------------------------+ The new query is a lot faster mysql> EXPLAIN SELECT revs.* FROM ( (SELECT revision.* FROM `differential_revision` revision WHERE revision.authorPHID in ('PHID-USER-a113b9ae4ee9524d0a20')) UNION (SELECT revision.* FROM `differential_revision` revision JOIN differential_relationship rel WHERE rel.revisionId = revision.Id AND rel.objectPHID = 'PHID-USER-a113b9ae4ee9524d0a20')) as revs LEFT JOIN `differential_viewtime` viewtime ON viewtime.viewerPHID = 'PHID-USER-a113b9ae4ee9524d0a20' AND viewtime.objectPHID = revs.phid WHERE GREATEST(1304022277, IFNULL(viewtime.viewTime, 0)) < revs.dateModified ORDER BY revs.dateModified; +----+--------------+------------+--------+--------------------+------------+---------+-----------------------------------------+------+--------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +----+--------------+------------+--------+--------------------+------------+---------+-----------------------------------------+------+--------------------------+ | 1 | PRIMARY | <derived2> | ALL | NULL | NULL | NULL | NULL | 3021 | Using filesort | | 1 | PRIMARY | viewtime | ref | PRIMARY | PRIMARY | 66 | const | 17 | Using where | | 2 | DERIVED | revision | ref | authorPHID | authorPHID | 67 | | 1040 | Using where | | 3 | UNION | rel | ref | PRIMARY,objectPHID | objectPHID | 66 | | 3822 | Using where; Using index | | 3 | UNION | revision | eq_ref | PRIMARY | PRIMARY | 4 | phabricator_differential.rel.revisionID | 1 | | | NULL | UNION RESULT | <union2,3> | ALL | NULL | NULL | NULL | NULL | NULL | | +----+--------------+------------+--------+--------------------+------------+---------+-----------------------------------------+------+--------------------------+ Test Plan: Loaded differential updates with new query, made sure page loaded quickly. Ran the query from the command-line, it took about .4 seconds. Reviewed By: Girish Reviewers: tuomaspelkonen, jungejason, Girish Commenters: btrahan CC: aran, btrahan, elynde, Girish Differential Revision: 181 |
||
---|---|---|
bin | ||
conf | ||
externals | ||
resources | ||
scripts | ||
src | ||
webroot | ||
.arcconfig | ||
.divinerconfig | ||
.gitignore | ||
README |
PROJECT STATUS: CAVEAT EMPTOR This is an unstable preview release. You can learn more at http://phabricator.org/ as well as click around our development install. Developer mailing list at https://groups.google.com/group/phabricator-dev and please report issues using GitHub. WHAT IS PHABRICATOR? Phabricator is a suite of web applications that facilitate software development tasks, particularly code review. The primary application in the suite is Differential, a code review tool. Phabricator is highly unstable and has many missing features! These applications are being brought over from Facebook's internal toolset, but there's a lot of stuff that hasn't made it over yet. Feel free to follow the project but you probably shouldn't try to install this yet unless you're extremely ambitious or just want to take a look at it. LICENSE Phabricator is released under the Apache 2.0 license except as otherwise noted. http://www.apache.org/licenses/LICENSE-2.0