dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #37115
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18982: Added unique, composite index on dataapproval table. Provides database integrity in terms of dupl...
------------------------------------------------------------
revno: 18982
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-04-22 16:09:57 +0200
message:
Added unique, composite index on dataapproval table. Provides database integrity in terms of duplicte dataapproval records, and improves approval query performance 20 x.
modified:
dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableCreator.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-core/src/main/java/org/hisp/dhis/startup/TableCreator.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableCreator.java 2015-04-21 18:32:37 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/startup/TableCreator.java 2015-04-22 14:09:57 +0000
@@ -28,6 +28,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.hisp.dhis.aggregation.AggregatedDataValueService;
import org.hisp.dhis.system.startup.AbstractStartupRoutine;
import org.springframework.beans.factory.annotation.Autowired;
@@ -39,6 +41,8 @@
public class TableCreator
extends AbstractStartupRoutine
{
+ private static final Log log = LogFactory.getLog( TableCreator.class );
+
// -------------------------------------------------------------------------
// Dependencies
// -------------------------------------------------------------------------
@@ -57,5 +61,21 @@
public void execute()
{
aggregatedDataValueService.createDataMart();
+
+ createSilently( "create unique index dataapproval_unique on dataapproval(datasetid,periodid,organisationunitid,attributeoptioncomboid,dataapprovallevelid)", "dataapproval_unique" );
+ }
+
+ private void createSilently( final String sql, final String name )
+ {
+ try
+ {
+ jdbcTemplate.execute( sql );
+
+ log.info( "Created table/index " + name );
+ }
+ catch ( Exception ex )
+ {
+ log.debug( "Table/index " + name + " exists" );
+ }
}
}