Skip to content

Commit

Permalink
avoid vacuum after copy as it is irrelevant
Browse files Browse the repository at this point in the history
  • Loading branch information
AnatolyUss committed Apr 8, 2020
1 parent b11a606 commit f725559
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 50 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ However, if you're not into Node.js, you can still use old and proven FromMySqlT
<a href="mailto:[email protected]?subject=FromMySqlToPostgreSql">[email protected]</a></p>

<h3>VERSION</h3>
<p>Current version is 1.4.2<br />
<p>Current version is 1.5.0<br />
(major version . improvements . bug fixes)</p>

<h3>TESTING</h3>
Expand Down
52 changes: 3 additions & 49 deletions migration/FromMySqlToPostgreSql/FromMySqlToPostgreSql.php
Original file line number Diff line number Diff line change
Expand Up @@ -1369,51 +1369,6 @@ private function processForeignKey($strTableName)
}
}

/**
* Runs "vacuum full" and "ANALYZE" for given table.
*
* @param string $strTableName
* @return void
*/
private function runVacuumFullAndAnalyze($strTableName)
{
$sql = '';

$this->log(
"\t" . '-- Running "VACUUM FULL and ANALYZE" query for table "'
. $this->strSchema . '"."' . $strTableName . '"...' . PHP_EOL
);

try {
$this->connect();
$sql = 'VACUUM (FULL, ANALYZE) "' . $this->strSchema . '"."' . $strTableName . '";';
$stmt = $this->pgsql->query($sql);

if (false === $stmt) {
$this->log(
"\t" . '-- Failed when run "VACUUM FULL and ANALYZE" query for table "'
. $this->strSchema . '"."' . $strTableName . '"...' . PHP_EOL
);

} else {
$this->log(
"\t" . '-- "VACUUM FULL and ANALYZE" procedure for table "'
. $this->strSchema . '"."' . $strTableName . '" has been successfully accomplished...' . PHP_EOL
);
}

unset($stmt, $sql);

} catch (\PDOException $e) {
$strMsg = __METHOD__ . PHP_EOL . "\t"
. '-- Error occurred when tried to run "VACUUM FULL and ANALYZE" query for table "'
. $this->strSchema . '"."' . $strTableName . '"...' . PHP_EOL;

$this->generateError($e, $strMsg, $sql);
unset($strMsg);
}
}

/**
* Set constraints (excluding foreign key constraints) for given table.
*
Expand Down Expand Up @@ -1571,13 +1526,12 @@ private function createConstraints()
}

/**
* Set foreign key constraints, then run "vacuum full" and "ANALYZE" for each table.
* Set foreign key constraints.
*/
private function createForeignKeysAndRunVacuumFullAndAnalyze()
private function createForeignKeys()
{
foreach ($this->arrTablesToMigrate as $arrTable) {
$this->processForeignKey($arrTable['Tables_in_' . $this->strMySqlDbName]);
$this->runVacuumFullAndAnalyze($arrTable['Tables_in_' . $this->strMySqlDbName]);
unset($arrTable);
}
}
Expand Down Expand Up @@ -1637,7 +1591,7 @@ public function migrate()

if (!$this->isDataOnly) {
$this->createConstraints();
$this->createForeignKeysAndRunVacuumFullAndAnalyze();
$this->createForeignKeys();
$this->createViews();
}

Expand Down

0 comments on commit f725559

Please sign in to comment.