Commit 038811b
Adding a partitioned reporting_patient_states table (#5614)
**Story card:**
[sc-15583](https://app.shortcut.com/simpledotorg/story/15583/new-reporting-pipeline-for-reporting-patient-states)
## Because
Materialized view refresh is very slow.
We want to introduce partitioned table approach, where with each month
it will drop that partition, regenerate data for that partition and
attach it to the main table.
With this new approach we will not be doing a full refresh of the table
every day.
## This addresses
This is the first step towards redesigning our reporting pipeline.
We are adding a partitioned reporting_patient_states table, under a
different schema. The Mat view version of same would continue to behave
as it is, until we decide to finally make the partitioned table live.
Dashboards are still going to use the mat view for getting the data.
When the daily rake task for runs, then for reporting_patient_states
will refresh only the current month and previous month.
We still want to refresh last 15 months data to handle delayed sync
scenario. So last 15 months data would be refreshed once at some point
during the current month.
There is a rake task for getting this table fully refreshed. This would
delete everything from the table and regenerate all the data from the
beginning. Ideally, this task would run only once, in the start when the
feature is deployed.
## Test instructions
Run the migrations.
rake "db:refresh_reporting_views" - for monthly/daily refresh
rake "reporting:full_partitioned_refresh" - for full refresh of
reporting_patient_states.
---------
Co-authored-by: Ayushi Agrawal <[email protected]>1 parent d7f09d1 commit 038811b
File tree
14 files changed
+1176
-4
lines changed- app
- jobs
- models/reports
- services
- db
- migrate
- lib/tasks
- spec
- jobs
- models/reports
- services
14 files changed
+1176
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
16 | 26 | | |
17 | 27 | | |
18 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
13 | 17 | | |
14 | 18 | | |
15 | 19 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
36 | 44 | | |
37 | 45 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
108 | 109 | | |
109 | | - | |
110 | 110 | | |
111 | 111 | | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
112 | 120 | | |
113 | 121 | | |
114 | 122 | | |
115 | | - | |
| 123 | + | |
116 | 124 | | |
117 | 125 | | |
118 | 126 | | |
119 | | - | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
120 | 130 | | |
121 | 131 | | |
122 | 132 | | |
| |||
0 commit comments