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

Use "pathIndex" in some owners package queries to improve query plans

Summary: Depends on D19184. Ref T11015. Now that we have a digest index column, we can improve some of the queries a bit.

Test Plan:
- Ran queries from revision pages before and after with and without EXPLAIN.
- Saw the same results with much better EXPLAIN plans.
- Fragment size is now fixed at 12 bytes per fragment, so we can shove more of them in a single query.

Maniphest Tasks: T11015

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

+26 -8
+15 -5
src/applications/owners/query/PhabricatorOwnersPackageQuery.php
··· 206 206 if ($this->paths !== null) { 207 207 $where[] = qsprintf( 208 208 $conn, 209 - 'rpath.path IN (%Ls)', 210 - $this->getFragmentsForPaths($this->paths)); 209 + 'rpath.pathIndex IN (%Ls)', 210 + $this->getFragmentIndexesForPaths($this->paths)); 211 211 } 212 212 213 213 if ($this->statuses !== null) { ··· 220 220 if ($this->controlMap) { 221 221 $clauses = array(); 222 222 foreach ($this->controlMap as $repository_phid => $paths) { 223 - $fragments = $this->getFragmentsForPaths($paths); 223 + $indexes = $this->getFragmentIndexesForPaths($paths); 224 224 225 225 $clauses[] = qsprintf( 226 226 $conn, 227 - '(rpath.repositoryPHID = %s AND rpath.path IN (%Ls))', 227 + '(rpath.repositoryPHID = %s AND rpath.pathIndex IN (%Ls))', 228 228 $repository_phid, 229 - $fragments); 229 + $indexes); 230 230 } 231 231 $where[] = implode(' OR ', $clauses); 232 232 } ··· 331 331 } 332 332 333 333 return $fragments; 334 + } 335 + 336 + private function getFragmentIndexesForPaths(array $paths) { 337 + $indexes = array(); 338 + 339 + foreach ($this->getFragmentsForPaths($paths) as $fragment) { 340 + $indexes[] = PhabricatorHash::digestForIndex($fragment); 341 + } 342 + 343 + return $indexes; 334 344 } 335 345 336 346
+8 -3
src/applications/owners/storage/PhabricatorOwnersPackage.php
··· 218 218 // and then merge results in PHP. 219 219 220 220 $rows = array(); 221 - foreach (array_chunk(array_keys($fragments), 128) as $chunk) { 221 + foreach (array_chunk(array_keys($fragments), 1024) as $chunk) { 222 + $indexes = array(); 223 + foreach ($chunk as $fragment) { 224 + $indexes[] = PhabricatorHash::digestForIndex($fragment); 225 + } 226 + 222 227 $rows[] = queryfx_all( 223 228 $conn, 224 229 'SELECT pkg.id, pkg.dominion, p.excluded, p.path 225 230 FROM %T pkg JOIN %T p ON p.packageID = pkg.id 226 - WHERE p.path IN (%Ls) AND pkg.status IN (%Ls) %Q', 231 + WHERE p.pathIndex IN (%Ls) AND pkg.status IN (%Ls) %Q', 227 232 $package->getTableName(), 228 233 $path->getTableName(), 229 - $chunk, 234 + $indexes, 230 235 array( 231 236 self::STATUS_ACTIVE, 232 237 ),
+3
src/applications/owners/storage/PhabricatorOwnersPath.php
··· 26 26 'columns' => array('packageID', 'repositoryPHID', 'pathIndex'), 27 27 'unique' => true, 28 28 ), 29 + 'key_repository' => array( 30 + 'columns' => array('repositoryPHID', 'pathIndex'), 31 + ), 29 32 ), 30 33 ) + parent::getConfiguration(); 31 34 }