Skip to content

Commit

Permalink
Optimize Patient Summaries MatView (#5515)
Browse files Browse the repository at this point in the history
**Story card:**
[sc-13796](https://app.shortcut.com/simpledotorg/story/13796/patient-line-list-returning-no-data-in-simple-dashboard-ethiopia)

## Because

We need a more efficient matview query which works across countries and
scales as Simple is used. Currently, the v03 fails in Ethiopia, causing
the line list to return an empty zip. V04 uses some advanced SQL to
optimize the query, and ensure it scales regardless of how much the
underlying data grows

## This addresses

- do away with lateral joins (joining the same set over and over)
- filter early
- do away with the non-performant `select *`
- leverage `lead()` and `lag()` to reduce joins


## Test instructions

See ticket for the run link
  • Loading branch information
igbanam authored Jan 9, 2025
1 parent d22b9e5 commit 8bdbf4e
Showing 1 changed file with 474 additions and 0 deletions.
Loading

0 comments on commit 8bdbf4e

Please sign in to comment.