Permalink
Browse files

Optimize feed query

Summary:
This was killing us. `EXPLAIN` after:

<table>
<tr><th>id</th><th>select_type</th><th>table</th><th>type</th><th>possible_keys</th><th>key</th><th>key_len</th><th>ref</th><th>rows</th><th>Extra</th></tr>
<tr><td>1</td><td>SIMPLE</td><td>story</td><td>index</td><td>chronologicalKey</td><td>chronologicalKey</td><td>8</td><td></td><td>201</td><td> </td></tr>
<tr><td>1</td><td>SIMPLE</td><td>ref</td><td>ref</td><td>chronologicalKey</td><td>chronologicalKey</td><td>8</td><td>phabricator_feed.story.chronologicalKey</td><td>1</td><td>Using index</td></tr>
</table>

Test Plan: /feed/

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin

Differential Revision: https://secure.phabricator.com/D3628
  • Loading branch information...
1 parent 5578ccd commit 511a8bae34ebf0a91b54877828f75065c570b705 vrana committed Oct 4, 2012
@@ -139,6 +139,7 @@ private function buildFeedResponse($nav, array $projects) {
$filter = $subnav->selectFilter($this->subfilter, 'all');
+ $view = null;
switch ($filter) {
case 'all':
$view = $this->buildFeedView(array());
@@ -76,11 +76,15 @@ private function buildWhereClause(AphrontDatabaseConnection $conn_r) {
private function buildGroupClause(AphrontDatabaseConnection $conn_r) {
return qsprintf(
$conn_r,
- 'GROUP BY ref.chronologicalKey');
+ 'GROUP BY '.($this->filterPHIDs
+ ? 'ref.chronologicalKey'
+ : 'story.chronologicalKey'));
}
protected function getPagingColumn() {
- return 'ref.chronologicalKey';
+ return ($this->filterPHIDs
+ ? 'ref.chronologicalKey'
+ : 'story.chronologicalKey');
}
protected function getPagingValue($item) {

0 comments on commit 511a8ba

Please sign in to comment.