Add New Index On HFJ_RESOURCE For $reindex Operation (#3536)
* 3534 - Added new multi-column Index and removed existing single-column Index. * 3534 - Added PARTITION_ID to the new Index. * Change migrations to have no timeout. Co-authored-by: Michael Buckley <michael.buckley@smilecdr.com>
This commit is contained in:
parent
68c8523046
commit
dd5ab4ede7
|
@ -0,0 +1,3 @@
|
|||
type: add
|
||||
issue: 3534
|
||||
title: "Added a new multi-column index on the HFJ_RESOURCE table indexing the columns RES_TYPE, RES_DELETED_AT, RES_UPDATED, PARTITION_ID and RES_ID and removed the existing single-column index on the RES_TYPE column. This new index will improve the performance of the $reindex operation and will be useful for some other queries a well."
|
|
@ -0,0 +1,5 @@
|
|||
type: change
|
||||
issue: 3534
|
||||
title: "Ensure that migration steps do not timeout.
|
||||
Adding an index, and other migration steps can take exceed the default connection timeout.
|
||||
This has been changed - migration steps now have no timeout and will run until completion."
|
|
@ -288,6 +288,19 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
|||
version
|
||||
.onTable("HFJ_BLK_EXPORT_JOB").modifyColumn("20220423.1", "EXP_TIME").nullable().withType(ColumnTypeEnum.DATE_TIMESTAMP);
|
||||
|
||||
// New Index on HFJ_RESOURCE for $reindex Operation - hapi-fhir #3534
|
||||
{
|
||||
version.onTable("HFJ_RESOURCE")
|
||||
.addIndex("20220425.1", "IDX_RES_TYPE_DEL_UPDATED")
|
||||
.unique(false)
|
||||
.online(true)
|
||||
.withColumns("RES_TYPE", "RES_DELETED_AT", "RES_UPDATED", "PARTITION_ID", "RES_ID");
|
||||
|
||||
// Drop existing Index on HFJ_RESOURCE.RES_TYPE since the new Index will meet the overall Index Demand
|
||||
version
|
||||
.onTable("HFJ_RESOURCE")
|
||||
.dropIndexOnline("20220425.2", "IDX_RES_TYPE");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -73,9 +73,9 @@ import java.util.stream.Collectors;
|
|||
@Indexed(routingBinder= @RoutingBinderRef(type = ResourceTableRoutingBinder.class))
|
||||
@Entity
|
||||
@Table(name = "HFJ_RESOURCE", uniqueConstraints = {}, indexes = {
|
||||
// Do not reuse previously used index name: IDX_INDEXSTATUS
|
||||
// Do not reuse previously used index name: IDX_INDEXSTATUS, IDX_RES_TYPE
|
||||
@Index(name = "IDX_RES_DATE", columnList = "RES_UPDATED"),
|
||||
@Index(name = "IDX_RES_TYPE", columnList = "RES_TYPE"),
|
||||
@Index(name = "IDX_RES_TYPE_DEL_UPDATED", columnList = "RES_TYPE,RES_DELETED_AT,RES_UPDATED,PARTITION_ID,RES_ID"),
|
||||
})
|
||||
@NamedEntityGraph(name = "Resource.noJoins")
|
||||
public class ResourceTable extends BaseHasResource implements Serializable, IBasePersistedResource, IResourceLookup {
|
||||
|
|
|
@ -162,6 +162,8 @@ public abstract class BaseTask {
|
|||
|
||||
private int doExecuteSql(@Language("SQL") String theSql, Object[] theArguments) {
|
||||
JdbcTemplate jdbcTemplate = getConnectionProperties().newJdbcTemplate();
|
||||
// 0 means no timeout -- we use this for index rebuilds that may take time.
|
||||
jdbcTemplate.setQueryTimeout(0);
|
||||
try {
|
||||
int changesCount = jdbcTemplate.update(theSql, theArguments);
|
||||
if (!"true".equals(System.getProperty("unit_test_mode"))) {
|
||||
|
|
Loading…
Reference in New Issue