-
-
Notifications
You must be signed in to change notification settings - Fork 151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(scrapers.admin): create materialized view and admin page #4662
base: main
Are you sure you want to change the base?
Conversation
Concept for #3950 For this to work, the materialized view must be created directly on the DB
We haven't used MV's before, so I have questions:
|
To do this kind of queries we have 3 options
In the case of this query, I don't think a new index would help. I think the slowness comes from joining big tables. Some query optimization may help reduce it more. The raw version takes 10 minutes, prefiltering the docket table by courts that have scrapers takes it down to 3 minutes Why bother materializing it?
How to refresh it Or, we could implement the refresh logic as an async call when accessing the admin page, and send a django admin message (those banners when editing an object) to the user advising to refresh the page in a few minutes |
Hm, in the past we had a script that would send an email with this kind of information, and it ran on a cron job, so I guess this is basically the same thing, but instead of storing the results of the script in an email, this stores the results in the materialized view. Seems fine, I suppose. :) |
- Includes a migration file for the materialized view - MV will have to be refreshed manually or via a cronjob - MV considers only courts that have an active scraper, and that have no updates in a week
To test this on a local environment
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One comment so far. We also need an admin task to update the view, right? Want to include that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We wouldn't need this for the replicas.
Concept for #3950
For this to work, the materialized view must be created directly on the DB by running the "query" attribute
For my local database, it looks like this
But, if if connected to the live DB, it would have these rows: