Skip to content

Commit

Permalink
feat: vacuum strategy for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
Nolife999 committed Nov 22, 2024
1 parent 54b31f1 commit ad1cb50
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion arc-batch/src/main/java/fr/insee/arc/batch/BatchARC.java
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ private void startMaintenanceThread() {
@Override
public void run() {
try {
DatabaseMaintenance.maintenancePgCatalogAllNods(null, FormatSQL.VACUUM_OPTION_FREEZE);
DatabaseMaintenance.maintenancePgCatalogAllNods(null, FormatSQL.VACUUM_OPTION_NONE);
DatabaseMaintenance.maintenancePilotage(null, envExecution, FormatSQL.VACUUM_OPTION_NONE);
} catch (ArcException e) {
e.logMessageException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public void executer() throws ArcException {
// Met en cohérence les tables de données avec la table de pilotage de
// l'environnement
// La table de pilotage fait foi
new SynchronizeDataByPilotageOperation(this.coordinatorSandbox).synchronizeDataByPilotage(true);
new SynchronizeDataByPilotageOperation(this.coordinatorSandbox).synchronizeDataByPilotage();

// remettre les archives ou elle doivent etre en cas de restauration de la base
new RestoreFileSystem(this.coordinatorSandbox).execute();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public static void resetBAS(String env, String rootDirectory) {
new ResetEnvironmentOperation(service.getCoordinatorSandbox()).clearPilotageAndDirectories(rootDirectory);

// synchronize
new SynchronizeDataByPilotageOperation(service.getCoordinatorSandbox()).synchronizeDataByPilotage(false);
new SynchronizeDataByPilotageOperation(service.getCoordinatorSandbox()).synchronizeDataByPilotage();

} catch (ArcException e) {
e.logFullException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public SynchronizeDataByPilotageOperation(Sandbox sandbox) {
* @param envExecution
* @throws ArcException
*/
public void synchronizeDataByPilotage(boolean fullRebuild) throws ArcException {
public void synchronizeDataByPilotage() throws ArcException {
LoggerHelper.info(LOGGER, "synchronisationEnvironmentByPilotage");

// maintenance de la table de pilotage
Expand All @@ -54,7 +54,7 @@ public void synchronizeDataByPilotage(boolean fullRebuild) throws ArcException {
resetEtapePilotage();

// recrée la table de pilotage, ses index, son trigger
rebuildPilotage(fullRebuild);
rebuildPilotage();

// drop des tables temporaires de travail
dropUnusedTemporaryTablesAllNods();
Expand Down Expand Up @@ -88,8 +88,8 @@ private void resetEtapePilotage() throws ArcException {



private void rebuildPilotage(boolean fullRebuild) throws ArcException {
SynchronizeDataByPilotageDao.rebuildPilotageDao(this.sandbox.getConnection(), this.sandbox.getSchema(), fullRebuild);
private void rebuildPilotage() throws ArcException {
SynchronizeDataByPilotageDao.rebuildPilotageDao(this.sandbox.getConnection(), this.sandbox.getSchema());
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ public void execQueryMaintenancePilotage() throws ArcException
{
StringBuilder query = new StringBuilder();
query.append(FormatSQL.vacuumSecured(ViewEnum.PILOTAGE_FICHIER.getFullName(sandbox.getSchema()), FormatSQL.VACUUM_OPTION_ANALYZE));
query.append(FormatSQL.vacuumSecured(ViewEnum.PILOTAGE_ARCHIVE.getFullName(sandbox.getSchema()), FormatSQL.VACUUM_OPTION_ANALYZE));
query.append(FormatSQL.vacuumSecured(ViewEnum.PILOTAGE_ARCHIVE.getFullName(sandbox.getSchema()), FormatSQL.VACUUM_OPTION_FREEZE));
query.append(FormatSQL.analyzeSecured(ViewEnum.PILOTAGE_ARCHIVE.getFullName(sandbox.getSchema())));

UtilitaireDao.get(0).executeImmediate(sandbox.getConnection(), query);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ public static void resetEtapePilotageDao(Connection connection, String envExecut
* @param envExecution
* @throws ArcException
*/
public static void rebuildPilotageDao(Connection connexion, String envExecution, boolean fullRebuild) throws ArcException {
public static void rebuildPilotageDao(Connection connexion, String envExecution) throws ArcException {

String tablePilotage = ViewEnum.PILOTAGE_FICHIER.getFullName(envExecution);

UtilitaireDao.get(0).executeImmediate(connexion, FormatSQL.vacuumSecured(tablePilotage, fullRebuild?FormatSQL.VACUUM_OPTION_FULL:FormatSQL.VACUUM_OPTION_NONE));
UtilitaireDao.get(0).executeImmediate(connexion, FormatSQL.vacuumSecured(tablePilotage, FormatSQL.VACUUM_OPTION_FREEZE));

UtilitaireDao.get(0).executeImmediate(connexion, FormatSQL.analyzeSecured(tablePilotage));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public void retourPhasePrecedente(TraitementPhase phase, List<String> querySelec
nbLignes += resetEnvironmentDao.executeDeletePhaseEntriesInPilotageAndCount(phase, querySelection);

// Run a database synchronization with the pilotage table
new SynchronizeDataByPilotageOperation(this.sandbox).synchronizeDataByPilotage(false);
new SynchronizeDataByPilotageOperation(this.sandbox).synchronizeDataByPilotage();

if (nbLignes > 0) {
DatabaseMaintenance.maintenanceDatabaseClassic(connection, envExecution);
Expand Down

0 comments on commit ad1cb50

Please sign in to comment.