dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37792
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19302: performance optimizations in DXF2 TEIService, adds explicit flushing, speeds up bulk imports abou...
------------------------------------------------------------
revno: 19302
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-06-08 10:24:16 +0700
message:
performance optimizations in DXF2 TEIService, adds explicit flushing, speeds up bulk imports about 5x
modified:
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java
dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstanceService.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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java 2015-06-08 03:02:05 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/AbstractTrackedEntityInstanceService.java 2015-06-08 03:24:16 +0000
@@ -29,6 +29,7 @@
*/
import com.google.common.collect.Lists;
+import org.hibernate.SessionFactory;
import org.hisp.dhis.common.CodeGenerator;
import org.hisp.dhis.common.Grid;
import org.hisp.dhis.common.IdentifiableObjectManager;
@@ -99,6 +100,9 @@
@Autowired
protected UserService userService;
+ @Autowired
+ protected SessionFactory sessionFactory;
+
// -------------------------------------------------------------------------
// READ
// -------------------------------------------------------------------------
@@ -202,10 +206,19 @@
public ImportSummaries addTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances )
{
ImportSummaries importSummaries = new ImportSummaries();
+ int counter = 0;
for ( TrackedEntityInstance trackedEntityInstance : trackedEntityInstances )
{
importSummaries.addImportSummary( addTrackedEntityInstance( trackedEntityInstance ) );
+
+ if ( counter % FLUSH_FREQUENCY == 0 )
+ {
+ sessionFactory.getCurrentSession().flush();
+ sessionFactory.getCurrentSession().clear();
+ }
+
+ counter++;
}
return importSummaries;
@@ -253,10 +266,19 @@
public ImportSummaries updateTrackedEntityInstances( List<TrackedEntityInstance> trackedEntityInstances )
{
ImportSummaries importSummaries = new ImportSummaries();
+ int counter = 0;
for ( TrackedEntityInstance trackedEntityInstance : trackedEntityInstances )
{
importSummaries.addImportSummary( updateTrackedEntityInstance( trackedEntityInstance ) );
+
+ if ( counter % FLUSH_FREQUENCY == 0 )
+ {
+ sessionFactory.getCurrentSession().flush();
+ sessionFactory.getCurrentSession().clear();
+ }
+
+ counter++;
}
return importSummaries;
=== modified file 'dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstanceService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstanceService.java 2015-06-08 03:02:05 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/trackedentity/TrackedEntityInstanceService.java 2015-06-08 03:24:16 +0000
@@ -41,6 +41,8 @@
*/
public interface TrackedEntityInstanceService
{
+ int FLUSH_FREQUENCY = 20;
+
// -------------------------------------------------------------------------
// READ
// -------------------------------------------------------------------------