Skip to content

Commit a193b82

Browse files
authored
Add index on foreign key column if parent exists to speed up queries (#356)
* add index on foreign key column if parent exists to speed up queries * Updated release notes
1 parent 7c5a793 commit a193b82

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

core/src/main/java/com/devonfw/tools/solicitor/writer/ResultDatabaseFactory.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,15 @@ private void createTable(AbstractModelObject modelObject) {
8282
String sql = sb.toString();
8383
this.jdbcTemplate.execute(sql);
8484

85+
// add index on foreign key column if parent exists to speed up queries
86+
if (modelObject.getParent() != null) {
87+
sb = new StringBuilder();
88+
sb.append("CREATE INDEX IDX_").append(name).append("_PARENT ON ").append(name).append(" (PARENT_").append(name)
89+
.append(");");
90+
sql = sb.toString();
91+
this.jdbcTemplate.execute(sql);
92+
}
93+
8594
}
8695

8796
/**

documentation/master-solicitor.asciidoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2026,7 +2026,8 @@ Spring beans implementing this interface will be called at certain points in the
20262026

20272027
[appendix]
20282028
== Release Notes
2029-
Changes in 1.48.0::
2029+
Changes in 1.47.1::
2030+
* https://github.com/devonfw/solicitor/pull/356: Fixed performance issue by adding indexes for SQL database tables used for reporting.
20302031

20312032
Changes in 1.47.0::
20322033
* https://github.com/devonfw/solicitor/issues/348: Support worksheet protection in reports generated by the `ExcelWriter`. See <<Excel sheet protection against unwanted manual changes>>.

0 commit comments

Comments
 (0)