Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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
  • Loading branch information...
commit 07db53b6f8db64c6d2aa4df7bb861e47dcbd93eb 1 parent ce1a585
vrana authored
Showing with 19 additions and 21 deletions.
  1. +19 −21 src/applications/differential/query/DifferentialRevisionQuery.php
View
40 src/applications/differential/query/DifferentialRevisionQuery.php
@@ -485,17 +485,29 @@ private function loadData() {
$conn_r = $table->establishConnection('r');
if ($this->draftAuthors) {
+ $this->draftRevisions = array();
+
$draft_key = 'differential-comment-';
$drafts = id(new PhabricatorDraft())->loadAllWhere(
'authorPHID IN (%Ls) AND draftKey LIKE %> AND draft != %s',
$this->draftAuthors,
$draft_key,
'');
- $this->draftRevisions = array();
$len = strlen($draft_key);
foreach ($drafts as $draft) {
$this->draftRevisions[] = substr($draft->getDraftKey(), $len);
}
+
+ $inlines = id(new DifferentialInlineComment())->loadAllWhere(
+ 'commentID IS NULL AND authorPHID IN (%Ls)',
+ $this->draftAuthors);
+ foreach ($inlines as $inline) {
+ $this->draftRevisions[] = $inline->getRevisionID();
+ }
+
+ if (!$this->draftRevisions) {
+ return array();
+ }
}
$select = qsprintf(
@@ -599,16 +611,6 @@ private function buildJoinsClause($conn_r) {
$this->responsibles);
}
- if ($this->draftAuthors) {
- $joins[] = qsprintf(
- $conn_r,
- 'LEFT JOIN %T inline_comment ON inline_comment.revisionID = r.id '.
- 'AND inline_comment.commentID IS NULL '.
- 'AND inline_comment.authorPHID IN (%Ls)',
- id(new DifferentialInlineComment())->getTableName(),
- $this->draftAuthors);
- }
-
$joins = implode(' ', $joins);
return $joins;
@@ -642,17 +644,13 @@ private function buildWhereClause($conn_r) {
$this->authors);
}
- if ($this->draftAuthors) {
- $condition = 'inline_comment.id IS NOT NULL';
- if ($this->draftRevisions) {
- $condition = qsprintf(
- $conn_r,
- '(%Q OR r.id IN (%Ld))',
- $condition,
- $this->draftRevisions);
- }
- $where[] = $condition;
+ if ($this->draftRevisions) {
+ $where[] = qsprintf(
+ $conn_r,
+ 'r.id IN (%Ld)',
+ $this->draftRevisions);
}
+
if ($this->revIDs) {
$where[] = qsprintf(
$conn_r,
Please sign in to comment.
Something went wrong with that request. Please try again.