Skip to content

Commit 21a56ea

Browse files
aagrawalrtslAyushi Agrawal
andauthored
optimizing reporting_patient_states partitioned refresh (#5700)
**Story card:** [sc-16750](https://app.shortcut.com/simpledotorg/story/16750/make-partitioned-refresh-performant) ## Because In India partitioned refresh was running for 2 weeks, which is not acceptable. ## This addresses Adding a month_date index on reporting_prescriptions to make the join, which provides "titrated" column, faster. Using an indexed field, month_date, for joins in reporting_patient_blood_sugars, reporting_patient_blood_pressures and reporting_patient_visits to improve the overall performance. ## Test instructions Run `rake "db:refresh_reporting_views"` For small dataset, this optimization is not measurable. We tested this in India prod, after these optimizations, refresh was completed in 15 mins. --------- Co-authored-by: Ayushi Agrawal <[email protected]>
1 parent cd2124f commit 21a56ea

File tree

3 files changed

+447
-6
lines changed

3 files changed

+447
-6
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
class AddMonthDateIndexReportingPrescriptions < ActiveRecord::Migration[6.1]
2+
self.disable_ddl_transaction = true
3+
4+
def up
5+
add_index :reporting_prescriptions, [:month_date],
6+
name: "reporting_prescriptions_month_date", algorithm: :concurrently
7+
end
8+
9+
def down
10+
remove_index :reporting_prescriptions,
11+
name: "reporting_prescriptions_month_date"
12+
end
13+
end

0 commit comments

Comments
 (0)