mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 16:52:41 +01:00
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
This commit is contained in:
parent
df1e9ce646
commit
516aaad341
3 changed files with 26 additions and 8 deletions
|
@ -206,8 +206,8 @@ final class PhabricatorOwnersPackageQuery
|
|||
if ($this->paths !== null) {
|
||||
$where[] = qsprintf(
|
||||
$conn,
|
||||
'rpath.path IN (%Ls)',
|
||||
$this->getFragmentsForPaths($this->paths));
|
||||
'rpath.pathIndex IN (%Ls)',
|
||||
$this->getFragmentIndexesForPaths($this->paths));
|
||||
}
|
||||
|
||||
if ($this->statuses !== null) {
|
||||
|
@ -220,13 +220,13 @@ final class PhabricatorOwnersPackageQuery
|
|||
if ($this->controlMap) {
|
||||
$clauses = array();
|
||||
foreach ($this->controlMap as $repository_phid => $paths) {
|
||||
$fragments = $this->getFragmentsForPaths($paths);
|
||||
$indexes = $this->getFragmentIndexesForPaths($paths);
|
||||
|
||||
$clauses[] = qsprintf(
|
||||
$conn,
|
||||
'(rpath.repositoryPHID = %s AND rpath.path IN (%Ls))',
|
||||
'(rpath.repositoryPHID = %s AND rpath.pathIndex IN (%Ls))',
|
||||
$repository_phid,
|
||||
$fragments);
|
||||
$indexes);
|
||||
}
|
||||
$where[] = implode(' OR ', $clauses);
|
||||
}
|
||||
|
@ -333,6 +333,16 @@ final class PhabricatorOwnersPackageQuery
|
|||
return $fragments;
|
||||
}
|
||||
|
||||
private function getFragmentIndexesForPaths(array $paths) {
|
||||
$indexes = array();
|
||||
|
||||
foreach ($this->getFragmentsForPaths($paths) as $fragment) {
|
||||
$indexes[] = PhabricatorHash::digestForIndex($fragment);
|
||||
}
|
||||
|
||||
return $indexes;
|
||||
}
|
||||
|
||||
|
||||
/* -( Path Control )------------------------------------------------------- */
|
||||
|
||||
|
|
|
@ -218,15 +218,20 @@ final class PhabricatorOwnersPackage
|
|||
// and then merge results in PHP.
|
||||
|
||||
$rows = array();
|
||||
foreach (array_chunk(array_keys($fragments), 128) as $chunk) {
|
||||
foreach (array_chunk(array_keys($fragments), 1024) as $chunk) {
|
||||
$indexes = array();
|
||||
foreach ($chunk as $fragment) {
|
||||
$indexes[] = PhabricatorHash::digestForIndex($fragment);
|
||||
}
|
||||
|
||||
$rows[] = queryfx_all(
|
||||
$conn,
|
||||
'SELECT pkg.id, pkg.dominion, p.excluded, p.path
|
||||
FROM %T pkg JOIN %T p ON p.packageID = pkg.id
|
||||
WHERE p.path IN (%Ls) AND pkg.status IN (%Ls) %Q',
|
||||
WHERE p.pathIndex IN (%Ls) AND pkg.status IN (%Ls) %Q',
|
||||
$package->getTableName(),
|
||||
$path->getTableName(),
|
||||
$chunk,
|
||||
$indexes,
|
||||
array(
|
||||
self::STATUS_ACTIVE,
|
||||
),
|
||||
|
|
|
@ -26,6 +26,9 @@ final class PhabricatorOwnersPath extends PhabricatorOwnersDAO {
|
|||
'columns' => array('packageID', 'repositoryPHID', 'pathIndex'),
|
||||
'unique' => true,
|
||||
),
|
||||
'key_repository' => array(
|
||||
'columns' => array('repositoryPHID', 'pathIndex'),
|
||||
),
|
||||
),
|
||||
) + parent::getConfiguration();
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue