mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-22 14:52:41 +01:00
Improve performance of two recent commit migrations
Summary: Ref T13216. See PHI959. These two recent migrations can be expressed more efficiently: - When updating commit audit statuses, the field isn't JSON encoded or anything so we can just issue several bulk UPDATEs. - When inserting mail keys, we can batch them in groups of 100. Test Plan: Used `bin/storage upgrade -f --apply phabricator:...` to reapply patches. Saw equivalent behavior and faster runtimes. Reviewers: amckinley Reviewed By: amckinley Subscribers: PHID-OPKG-gm6ozazyms6q6i22gyam Maniphest Tasks: T13216 Differential Revision: https://secure.phabricator.com/D19802
This commit is contained in:
parent
86fd204148
commit
96f9b0917e
2 changed files with 25 additions and 23 deletions
|
@ -12,17 +12,11 @@ $status_map = array(
|
|||
5 => 'needs-verification',
|
||||
);
|
||||
|
||||
foreach (new LiskMigrationIterator($table) as $commit) {
|
||||
$status = $commit->getAuditStatus();
|
||||
|
||||
if (!isset($status_map[$status])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($status_map as $old_status => $new_status) {
|
||||
queryfx(
|
||||
$conn,
|
||||
'UPDATE %T SET auditStatus = %s WHERE id = %d',
|
||||
$table->getTableName(),
|
||||
$status_map[$status],
|
||||
$commit->getID());
|
||||
'UPDATE %R SET auditStatus = %s WHERE auditStatus = %s',
|
||||
$table,
|
||||
$new_status,
|
||||
$old_status);
|
||||
}
|
||||
|
|
|
@ -8,14 +8,13 @@ $properties_table = new PhabricatorMetaMTAMailProperties();
|
|||
$conn = $properties_table->establishConnection('w');
|
||||
|
||||
$iterator = new LiskRawMigrationIterator($commit_conn, $commit_name);
|
||||
foreach ($iterator as $commit) {
|
||||
queryfx(
|
||||
$chunks = new PhutilChunkedIterator($iterator, 100);
|
||||
foreach ($chunks as $chunk) {
|
||||
$sql = array();
|
||||
foreach ($chunk as $commit) {
|
||||
$sql[] = qsprintf(
|
||||
$conn,
|
||||
'INSERT IGNORE INTO %T
|
||||
(objectPHID, mailProperties, dateCreated, dateModified)
|
||||
VALUES
|
||||
(%s, %s, %d, %d)',
|
||||
$properties_table->getTableName(),
|
||||
'(%s, %s, %d, %d)',
|
||||
$commit['phid'],
|
||||
phutil_json_encode(
|
||||
array(
|
||||
|
@ -23,4 +22,13 @@ foreach ($iterator as $commit) {
|
|||
)),
|
||||
PhabricatorTime::getNow(),
|
||||
PhabricatorTime::getNow());
|
||||
}
|
||||
|
||||
queryfx(
|
||||
$conn,
|
||||
'INSERT IGNORE INTO %R
|
||||
(objectPHID, mailProperties, dateCreated, dateModified)
|
||||
VALUES %LQ',
|
||||
$properties_table,
|
||||
$sql);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue