dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #14105
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4657: Improved performance of the delete-existing-data step in datamart, down 75%
------------------------------------------------------------
revno: 4657
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2011-09-23 16:45:35 +0200
message:
Improved performance of the delete-existing-data step in datamart, down 75%
modified:
dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueService.java
dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStore.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedDataValueService.java
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java
dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java
--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk
Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueService.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueService.java 2011-08-24 20:25:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueService.java 2011-09-23 14:45:35 +0000
@@ -180,6 +180,22 @@
Collection<Integer> organisationUnitIds );
/**
+ * Deletes AggregatedDataValues registered for the given parameters.
+ *
+ * @param periodIds a collection of Period identifiers.
+ * @return the number of deleted AggregatedDataValues.
+ */
+ int deleteAggregatedDataValues( Collection<Integer> periodIds );
+
+ /**
+ * Deletes AggregatedIndicatorValue registered for the given parameters.
+ *
+ * @param periodIds a collection of Period identifiers.
+ * @return the number of deleted AggregatedIndicatorValues.
+ */
+ int deleteAggregatedIndicatorValues( Collection<Integer> periodIds );
+
+ /**
* Deletes all AggregatedDataValues.
*
* @return the number of deleted AggregatedDataValues.
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStore.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStore.java 2011-08-24 20:25:14 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/aggregation/AggregatedDataValueStore.java 2011-09-23 14:45:35 +0000
@@ -157,6 +157,14 @@
Collection<Integer> organisationUnitIds );
/**
+ * Deletes AggregatedDataValues registered for the given parameters.
+ *
+ * @param periodIds a collection of Period identifiers.
+ * @return the number of deleted AggregatedDataValues.
+ */
+ int deleteAggregatedDataValues( Collection<Integer> periodIds );
+
+ /**
* Deletes all AggregatedDataValues.
*
* @return the number of deleted AggregatedDataValues.
@@ -257,6 +265,14 @@
*/
int deleteAggregatedIndicatorValues( Collection<Integer> indicatorIds, Collection<Integer> periodIds,
Collection<Integer> organisationUnitIds );
+
+ /**
+ * Deletes AggregatedIndicatorValue registered for the given parameters.
+ *
+ * @param periodIds a collection of Period identifiers.
+ * @return the number of deleted AggregatedIndicatorValues.
+ */
+ int deleteAggregatedIndicatorValues( Collection<Integer> periodIds );
/**
* Deletes all AggregatedIndicatorValue.
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedDataValueService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedDataValueService.java 2011-08-24 20:25:14 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/DefaultAggregatedDataValueService.java 2011-09-23 14:45:35 +0000
@@ -122,6 +122,11 @@
{
return aggregatedDataValueStore.deleteAggregatedDataValues( dataElementIds, periodIds, organisationUnitIds );
}
+
+ public int deleteAggregatedDataValues( Collection<Integer> periodIds )
+ {
+ return aggregatedDataValueStore.deleteAggregatedDataValues( periodIds );
+ }
public int deleteAggregatedDataValues()
{
@@ -187,19 +192,22 @@
{
return aggregatedDataValueStore.deleteAggregatedIndicatorValues( indicatorIds, periodIds, organisationUnitIds );
}
+
+ public int deleteAggregatedIndicatorValues( Collection<Integer> periodIds )
+ {
+ return aggregatedDataValueStore.deleteAggregatedIndicatorValues( periodIds );
+ }
public int deleteAggregatedIndicatorValues()
{
return aggregatedDataValueStore.deleteAggregatedIndicatorValues();
}
- @Override
public StoreIterator<AggregatedIndicatorValue> getAggregateIndicatorValuesAtLevel( OrganisationUnit orgunit, OrganisationUnitLevel level, Collection<Period> periods )
{
return aggregatedDataValueStore.getAggregatedIndicatorValuesAtLevel( orgunit, level, periods );
}
- @Override
public int countIndicatorValuesAtLevel( OrganisationUnit orgunit, OrganisationUnitLevel level, Collection<Period> periods )
{
return aggregatedDataValueStore.countIndicatorValuesAtLevel( orgunit, level, periods );
=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java 2011-08-24 20:25:14 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/aggregation/jdbc/JdbcAggregatedDataValueStore.java 2011-09-23 14:45:35 +0000
@@ -290,7 +290,6 @@
}
}
- @Override
public StoreIterator<AggregatedDataValue> getAggregatedDataValuesAtLevel( OrganisationUnit rootOrgunit, OrganisationUnitLevel level, Collection<Period> periods )
{
final StatementHolder holder = statementManager.getHolder();
@@ -329,7 +328,6 @@
}
}
- @Override
public int countDataValuesAtLevel( OrganisationUnit rootOrgunit, OrganisationUnitLevel level, Collection<Period> periods )
{
final String periodids = getCommaDelimitedString( getIdentifiers(Period.class, periods));
@@ -356,6 +354,15 @@
return statementManager.getHolder().executeUpdate( sql );
}
+ public int deleteAggregatedDataValues( Collection<Integer> periodIds )
+ {
+ final String sql =
+ "DELETE FROM aggregateddatavalue " +
+ "WHERE periodid IN ( " + getCommaDelimitedString( periodIds ) + " )";
+
+ return statementManager.getHolder().executeUpdate( sql );
+ }
+
public int deleteAggregatedDataValues()
{
return statementManager.getHolder().executeUpdate( "DELETE FROM aggregateddatavalue" );
@@ -538,6 +545,15 @@
return statementManager.getHolder().executeUpdate( sql );
}
+
+ public int deleteAggregatedIndicatorValues( Collection<Integer> periodIds )
+ {
+ final String sql =
+ "DELETE FROM aggregatedindicatorvalue " +
+ "WHERE periodid IN ( " + getCommaDelimitedString( periodIds ) + " )";
+
+ return statementManager.getHolder().executeUpdate( sql );
+ }
public int deleteAggregatedIndicatorValues()
{
@@ -797,7 +813,7 @@
while ( resultSet.next() )
{
- final DataElementOperand operand = new DataElementOperand( resultSet.getInt( 1 ), resultSet.getInt( 2 ), null );
+ final DataElementOperand operand = new DataElementOperand( resultSet.getInt( 1 ), resultSet.getInt( 2 ) );
map.put( operand, resultSet.getString( 3 ) );
}
=== modified file 'dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java'
--- dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2011-08-29 19:26:15 +0000
+++ dhis-2/dhis-services/dhis-service-datamart-default/src/main/java/org/hisp/dhis/datamart/engine/DefaultDataMartEngine.java 2011-09-23 14:45:35 +0000
@@ -245,9 +245,16 @@
// Delete existing aggregated data
// ---------------------------------------------------------------------
- aggregatedDataValueService.deleteAggregatedDataValues( dataElementIds, periodIds, organisationUnitIds );
-
- aggregatedDataValueService.deleteAggregatedIndicatorValues( indicatorIds, periodIds, organisationUnitIds );
+ if ( completeExport )
+ {
+ aggregatedDataValueService.deleteAggregatedDataValues( periodIds );
+ aggregatedDataValueService.deleteAggregatedIndicatorValues( periodIds );
+ }
+ else
+ {
+ aggregatedDataValueService.deleteAggregatedDataValues( dataElementIds, periodIds, organisationUnitIds );
+ aggregatedDataValueService.deleteAggregatedIndicatorValues( indicatorIds, periodIds, organisationUnitIds );
+ }
clock.logTime( "Deleted existing aggregated data" );