Skip to content

Commit 1b3edb4

Browse files
authored
Add New Index IDX_RL_SRCPATH_TGTURL To HFJ_RES_LINK Table (#7224)
1 parent 6eb3d03 commit 1b3edb4

File tree

3 files changed

+22
-1
lines changed

3 files changed

+22
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
type: add
3+
issue: 7223
4+
title: "Add a new DB Index to the HFJ_RES_LINK Table called IDX_RL_SRCPATH_TGTURL to avoid Full Table Scans for certain queries."

hapi-fhir-jpaserver-base/src/main/java/ca/uhn/fhir/jpa/migrate/tasks/HapiFhirJpaMigrationTasks.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,19 @@ public HapiFhirJpaMigrationTasks(Set<String> theFlags) {
130130
init780();
131131
init820();
132132
init840();
133+
init860();
134+
}
135+
136+
protected void init860() {
137+
Builder version = forVersion(VersionEnum.V8_6_0);
138+
// Add IDX_RL_SRCPATH_TGTURL to the HFJ_RES_LINK Table - HAPI-FHIR #7223
139+
{
140+
version.onTable("HFJ_RES_LINK")
141+
.addIndex("20250827.01", "IDX_RL_SRCPATH_TGTURL")
142+
.unique(false)
143+
.withColumns("SRC_PATH, TARGET_RESOURCE_URL, PARTITION_ID, SRC_RESOURCE_ID")
144+
.heavyweightSkipByDefault();
145+
}
133146
}
134147

135148
protected void init840() {

hapi-fhir-jpaserver-model/src/main/java/ca/uhn/fhir/jpa/model/entity/ResourceLink.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,11 @@
6161
// in separate block.
6262
@Index(
6363
name = "IDX_RL_TGT_v2",
64-
columnList = "TARGET_RESOURCE_ID, SRC_PATH, SRC_RESOURCE_ID, TARGET_RESOURCE_TYPE,PARTITION_ID")
64+
columnList = "TARGET_RESOURCE_ID, SRC_PATH, SRC_RESOURCE_ID, TARGET_RESOURCE_TYPE,PARTITION_ID"),
65+
// See https://github.com/hapifhir/hapi-fhir/issues/7223
66+
@Index(
67+
name = "IDX_RL_SRCPATH_TGTURL",
68+
columnList = "SRC_PATH, TARGET_RESOURCE_URL, PARTITION_ID, SRC_RESOURCE_ID")
6569
})
6670
@IdClass(IdAndPartitionId.class)
6771
public class ResourceLink extends BaseResourceIndex {

0 commit comments

Comments
 (0)