Skip to content

Commit

Permalink
Fixed deleting audit events from large audit database on postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
arnost-starosta committed Nov 13, 2018
1 parent 9c8e132 commit c0fcb2f
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -651,6 +651,8 @@ private void createTemporaryTable(Session session, final Dialect dialect, final
private String createDeleteQuery(String objectTable, String tempTable, String idColumnName) {
if (getConfiguration().isUsingMySqlCompatible()) {
return createDeleteQueryAsJoin(objectTable, tempTable, idColumnName);
} else if (getConfiguration().isUsingPostgreSQL()) {
return createDeleteQueryAsJoinPostgreSQL(objectTable, tempTable, idColumnName);
} else {
// todo consider using join for other databases as well
return createDeleteQueryAsSubquery(objectTable, tempTable, idColumnName);
Expand All @@ -662,6 +664,10 @@ private String createDeleteQueryAsJoin(String objectTable, String tempTable, Str
+ "WHERE main." + idColumnName + " = temp.id";
}

private String createDeleteQueryAsJoinPostgreSQL(String objectTable, String tempTable, String idColumnName) {
return "delete from " + objectTable + " main using " + tempTable + " temp where main." + idColumnName + " = temp.id";
}

private String createDeleteQueryAsSubquery(String objectTable, String tempTable, String idColumnName) {
StringBuilder sb = new StringBuilder();
sb.append("delete from ").append(objectTable);
Expand Down

0 comments on commit c0fcb2f

Please sign in to comment.