Skip to content

Commit

Permalink
reduces number of inserts
Browse files Browse the repository at this point in the history
  • Loading branch information
wivern authored and chrisknoll committed Mar 24, 2020
1 parent 99bad86 commit f3e4a26
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,13 @@ public String getCodesetQuery(ConceptSet[] conceptSets) {
// construct main target codeset query
String conceptExpressionQuery = conceptSetQueryBuilder.buildExpressionQuery(cs.expression);
// attach the conceptSetId to the result query from the expession query builder
String conceptSetInsert = String.format("INSERT INTO #Codesets (codeset_id, concept_id)\nSELECT %d as codeset_id, c.concept_id FROM (%s) C;", cs.id, conceptExpressionQuery);
String conceptSetInsert = String.format("SELECT %d as codeset_id, c.concept_id FROM (%s) C", cs.id, conceptExpressionQuery);
codesetInserts.add(conceptSetInsert);
}
}

codesetQuery = StringUtils.replace(codesetQuery, "@codesetInserts", StringUtils.join(codesetInserts, "\n"));
codesetQuery = StringUtils.replace(codesetQuery, "@codesetInserts", "INSERT INTO #Codesets (codeset_id, concept_id)\n"
+ StringUtils.join(codesetInserts, " UNION ALL \n")) + ";";
return codesetQuery;
}

Expand Down

0 comments on commit f3e4a26

Please sign in to comment.