Closed jadudm closed 6 months ago
For now, @sambodeme's goal will be a branch where we can run a particularly taxing query against an unmanaged materialized view. @sambodeme, could you drop the query in this thread?
Also, please feel free to rewrite/modify/etc. this ticket as needed. It... I don't know how I should have documented the spike/thinking differently.
Here is the query params: Date range: 10/1/2022-10/31/2022 ALN: 20 Findings: Any
From a question to the dev channel, the idea that we can use LEFT JOIN to construct the MATERIALIZED VIEW is very productive.
Collecting some related issues and PRs here for future navigators:
There are some outstanding follow-up tasks here, but this ticket is otherwise complete.
Our search is very non-performant.
This is because multiple reasons:
Proposed:
MATERIALIZED VIEW
We had discussed various strategies to cache/re-format tables that would be more performant.
Postgres has a notion of materialized views. A materialized view is... a view, but it is populated with data, and not dynamic at query-time. Think of it as a table, expressed by a query, that gets populated. As a result, it can be used for searches without incurring additional overhead.
Materialized views have a cost to create (in time and space), but once created, behave like other tables. They do not stay up to date with their "linked" tables, however. As a result, they must be periodically refreshed.
Solution sketch
https://github.com/GSA-TTS/FAC/tree/jadudm/materialized-views
This adds
run.sh
changes to drop and create a materialized view for our searchable data of interestsql
files indissemination
for the drop, creation, and refresh of materialized viewsThis will drop (if exists) and create (if not exists) a materialized view called
dissemination_combined
that combines general, federalaward, and finding rows. It only combines data where there are findings. So, this table is only of use if someone is searching for audits that have findings.use
fac materialized_views --drop
fac materialized_views --create
fac materialized_views --refresh
The third command could be triggered via GH Action periodically (daily? 2x daily? 4x daily?) to update the view.