Tune postgres settings for Hapi indexing. (#4712)
Tune postgress settings for Hapi indexing.
This commit is contained in:
parent
49a39c195c
commit
f1166fe0e6
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
type: perf
|
||||
issue: 4712
|
||||
title: "Postgres indexing settings have changed. Autovacuum will run more frequently, and hashed columns will track more most-frequent items."
|
|
@ -7,3 +7,19 @@ This release has breaking changes.
|
|||
Bulk export behaviour is changing in this release such that Binary resources created as part of the response will now be created in the partition that the bulk export was requested rather than in the DEFAULT partition as was being done previously.
|
||||
|
||||
Bulk import behaviour is changing in this release such that data imported as part of the request will now create resources in the partition that the bulk import was requested rather than in the DEFAULT partition as was being done previously.
|
||||
|
||||
The default statistics depth for many tables has changed for Postgres.
|
||||
This improves the performance of many queries.
|
||||
Users of Postgres may wish to ANALYZE the HFJ_SPIDX_* indexing tables to see these improvements immediately.
|
||||
```
|
||||
analyze hfj_spidx_coords;
|
||||
analyze hfj_spidx_date;
|
||||
analyze hfj_spidx_number;
|
||||
analyze hfj_spidx_quantity;
|
||||
analyze hfj_spidx_quantity_nrml;
|
||||
analyze hfj_spidx_string;
|
||||
analyze hfj_spidx_token;
|
||||
analyze hfj_spidx_uri;
|
||||
analyze hfj_res_link;
|
||||
```
|
||||
|
||||
|
|
|
@ -262,6 +262,47 @@ public class HapiFhirJpaMigrationTasks extends BaseMigrationTasks<VersionEnum> {
|
|||
.unique(false)
|
||||
.online(true)
|
||||
.withColumns("HASH_IDENTITY", "SP_LATITUDE", "SP_LONGITUDE", "RES_ID", "PARTITION_ID");
|
||||
|
||||
|
||||
// Postgres tuning.
|
||||
version.executeRawSqls("20230402.1", Map.of(DriverTypeEnum.POSTGRES_9_4, List.of(
|
||||
// we can't use convering index until the autovacuum runs for those rows, which kills index performance
|
||||
"ALTER TABLE hfj_resource SET (autovacuum_vacuum_scale_factor = 0.01)",
|
||||
"ALTER TABLE hfj_forced_id SET (autovacuum_vacuum_scale_factor = 0.01)",
|
||||
"ALTER TABLE hfj_res_link SET (autovacuum_vacuum_scale_factor = 0.01)",
|
||||
"ALTER TABLE hfj_spidx_coords SET (autovacuum_vacuum_scale_factor = 0.01)",
|
||||
"ALTER TABLE hfj_spidx_date SET (autovacuum_vacuum_scale_factor = 0.01)",
|
||||
"ALTER TABLE hfj_spidx_number SET (autovacuum_vacuum_scale_factor = 0.01)",
|
||||
"ALTER TABLE hfj_spidx_quantity SET (autovacuum_vacuum_scale_factor = 0.01)",
|
||||
"ALTER TABLE hfj_spidx_quantity_nrml SET (autovacuum_vacuum_scale_factor = 0.01)",
|
||||
"ALTER TABLE hfj_spidx_string SET (autovacuum_vacuum_scale_factor = 0.01)",
|
||||
"ALTER TABLE hfj_spidx_token SET (autovacuum_vacuum_scale_factor = 0.01)",
|
||||
"ALTER TABLE hfj_spidx_uri SET (autovacuum_vacuum_scale_factor = 0.01)",
|
||||
|
||||
// PG by default tracks the most common 100 values. But our hashes cover 100s of SPs and need greater depth.
|
||||
// Set stats depth to the max for hash_value columns, and 1000 for hash_identity (one per SP).
|
||||
"alter table hfj_res_link alter column src_path set statistics 10000",
|
||||
"alter table hfj_res_link alter column target_resource_id set statistics 10000",
|
||||
"alter table hfj_res_link alter column src_resource_id set statistics 10000",
|
||||
"alter table hfj_spidx_coords alter column hash_identity set statistics 1000",
|
||||
"alter table hfj_spidx_date alter column hash_identity set statistics 1000",
|
||||
"alter table hfj_spidx_number alter column hash_identity set statistics 1000",
|
||||
"alter table hfj_spidx_quantity alter column hash_identity set statistics 1000",
|
||||
"alter table hfj_spidx_quantity alter column hash_identity_and_units set statistics 10000",
|
||||
"alter table hfj_spidx_quantity alter column hash_identity_sys_units set statistics 10000",
|
||||
"alter table hfj_spidx_quantity_nrml alter column hash_identity set statistics 1000",
|
||||
"alter table hfj_spidx_quantity_nrml alter column hash_identity_and_units set statistics 10000",
|
||||
"alter table hfj_spidx_quantity_nrml alter column hash_identity_sys_units set statistics 10000",
|
||||
"alter table hfj_spidx_string alter column hash_identity set statistics 1000",
|
||||
"alter table hfj_spidx_string alter column hash_exact set statistics 10000",
|
||||
"alter table hfj_spidx_string alter column hash_norm_prefix set statistics 10000",
|
||||
"alter table hfj_spidx_token alter column hash_identity set statistics 1000",
|
||||
"alter table hfj_spidx_token alter column hash_sys set statistics 10000",
|
||||
"alter table hfj_spidx_token alter column hash_sys_and_value set statistics 10000",
|
||||
"alter table hfj_spidx_token alter column hash_value set statistics 10000",
|
||||
"alter table hfj_spidx_uri alter column hash_identity set statistics 1000",
|
||||
"alter table hfj_spidx_uri alter column hash_uri set statistics 10000"
|
||||
)));
|
||||
}
|
||||
|
||||
protected void init640() {
|
||||
|
|
Loading…
Reference in New Issue