@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.

Optimize loading draft revisions

Summary:
This is killing us since D3615.

Maybe we should also change `differential_inlinecomment` index <commentID> to <commentID, authorPHID>.

Test Plan: Checked queries at **/differential/** with comment drafts.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

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

vrana 07db53b6 ce1a5851

+19 -21
+19 -21
src/applications/differential/query/DifferentialRevisionQuery.php
··· 485 485 $conn_r = $table->establishConnection('r'); 486 486 487 487 if ($this->draftAuthors) { 488 + $this->draftRevisions = array(); 489 + 488 490 $draft_key = 'differential-comment-'; 489 491 $drafts = id(new PhabricatorDraft())->loadAllWhere( 490 492 'authorPHID IN (%Ls) AND draftKey LIKE %> AND draft != %s', 491 493 $this->draftAuthors, 492 494 $draft_key, 493 495 ''); 494 - $this->draftRevisions = array(); 495 496 $len = strlen($draft_key); 496 497 foreach ($drafts as $draft) { 497 498 $this->draftRevisions[] = substr($draft->getDraftKey(), $len); 499 + } 500 + 501 + $inlines = id(new DifferentialInlineComment())->loadAllWhere( 502 + 'commentID IS NULL AND authorPHID IN (%Ls)', 503 + $this->draftAuthors); 504 + foreach ($inlines as $inline) { 505 + $this->draftRevisions[] = $inline->getRevisionID(); 506 + } 507 + 508 + if (!$this->draftRevisions) { 509 + return array(); 498 510 } 499 511 } 500 512 ··· 599 611 $this->responsibles); 600 612 } 601 613 602 - if ($this->draftAuthors) { 603 - $joins[] = qsprintf( 604 - $conn_r, 605 - 'LEFT JOIN %T inline_comment ON inline_comment.revisionID = r.id '. 606 - 'AND inline_comment.commentID IS NULL '. 607 - 'AND inline_comment.authorPHID IN (%Ls)', 608 - id(new DifferentialInlineComment())->getTableName(), 609 - $this->draftAuthors); 610 - } 611 - 612 614 $joins = implode(' ', $joins); 613 615 614 616 return $joins; ··· 642 644 $this->authors); 643 645 } 644 646 645 - if ($this->draftAuthors) { 646 - $condition = 'inline_comment.id IS NOT NULL'; 647 - if ($this->draftRevisions) { 648 - $condition = qsprintf( 649 - $conn_r, 650 - '(%Q OR r.id IN (%Ld))', 651 - $condition, 652 - $this->draftRevisions); 653 - } 654 - $where[] = $condition; 647 + if ($this->draftRevisions) { 648 + $where[] = qsprintf( 649 + $conn_r, 650 + 'r.id IN (%Ld)', 651 + $this->draftRevisions); 655 652 } 653 + 656 654 if ($this->revIDs) { 657 655 $where[] = qsprintf( 658 656 $conn_r,