private void applyMerging(List<Detection> detections) throws Exception {
        PreparedStatement updateStatement = con.prepareStatement("UPDATE " + detectionTable + " SET groupID = ? WHERE detectionId = ? ");
        long startTime = System.nanoTime();
        long numUpdates = 0;
        for (Detection det : detections) {
            if (det.groupId != det.detectionId) {
                updateStatement.setLong(1, det.groupId);
                updateStatement.setLong(2, det.detectionId);
                updateStatement.executeUpdate();
                numUpdates += 1;
                if ((numUpdates % 1000) == 0) {
                    con.commit();
                    LOG.info("{} of {} in {} seconds", new Object[]{numUpdates, detections.size(), (System.nanoTime() - startTime) / 1000000000});
                }
            }
        }
        con.commit();
        long writeTime = (System.nanoTime() - startTime) / 1000000000;
        LOG.info("Wrote {} of {} updates in {} seconds", new Object[]{numUpdates, detections.size(), writeTime});
        updateStatement.close();
    }