aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-core
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-01-15 17:34:15 +0100
committerJulien HENRY <julien.henry@sonarsource.com>2015-01-15 17:35:25 +0100
commit1899835d7772f9930f5f997e0b665a8c02e404fa (patch)
tree3b05ec989ce06df6145b798bd0a3aeadb2709039 /sonar-core
parentfeaf31f478e1980c66297d7527b3d259112b3683 (diff)
downloadsonarqube-1899835d7772f9930f5f997e0b665a8c02e404fa.tar.gz
sonarqube-1899835d7772f9930f5f997e0b665a8c02e404fa.zip
Experimental optimization for truncate on Oracle
Diffstat (limited to 'sonar-core')
-rw-r--r--sonar-core/src/test/java/org/sonar/core/persistence/DatabaseCommands.java11
1 files changed, 10 insertions, 1 deletions
diff --git a/sonar-core/src/test/java/org/sonar/core/persistence/DatabaseCommands.java b/sonar-core/src/test/java/org/sonar/core/persistence/DatabaseCommands.java
index 03b0237a59d..52db5b3a811 100644
--- a/sonar-core/src/test/java/org/sonar/core/persistence/DatabaseCommands.java
+++ b/sonar-core/src/test/java/org/sonar/core/persistence/DatabaseCommands.java
@@ -63,6 +63,10 @@ public abstract class DatabaseCommands {
abstract List<String> resetPrimaryKey(String table, int minSequenceValue);
+ String getTruncateCommand(String table) {
+ return "TRUNCATE TABLE " + table;
+ }
+
public static DatabaseCommands forDialect(Dialect dialect) {
DatabaseCommands command = ImmutableMap.of(
org.sonar.core.persistence.dialect.H2.ID, H2,
@@ -96,6 +100,11 @@ public abstract class DatabaseCommands {
"DROP SEQUENCE " + sequence,
"CREATE SEQUENCE " + sequence + " INCREMENT BY 1 MINVALUE 1 START WITH " + minSequenceValue);
}
+
+ @Override
+ String getTruncateCommand(String table) {
+ return "TRUNCATE TABLE " + table + " REUSE STORAGE";
+ }
};
private static final DatabaseCommands MSSQL = new DatabaseCommands(new MsSqlDataTypeFactory()) {
@@ -128,7 +137,7 @@ public abstract class DatabaseCommands {
statement = connection.createStatement();
for (String table : DatabaseVersion.TABLES) {
try {
- statement.executeUpdate("TRUNCATE TABLE " + table);
+ statement.executeUpdate(getTruncateCommand(table));
connection.commit();
} catch (Exception e) {
// ignore