-
Notifications
You must be signed in to change notification settings - Fork 670
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
Improve performance for slow queries #6267
Comments
Working on this. |
Update: I’ve found a solution for the second issue. I’ll explain the approach later and then open a PR. Currently testing a few more things. |
My Local DB size:
Query Optimization ReportWhy the Current SQL Query is SlowCurrent SQL Query:SELECT DISTINCT articles.*
FROM articles
INNER JOIN articles_courses
ON articles.id = articles_courses.article_id
WHERE articles_courses.course_id = 22647
AND (articles.average_views_updated_at IS NULL
OR articles.average_views_updated_at < '2025-03-05')
ORDER BY articles.id ASC
LIMIT 200; Issues Identified: 1. Index Misuse
-
|
Hi @gabina, whenever you have time, could you please take a look at the |
@Abishekcs thanks! This looks very promising. Is there a straightforward way to implement it? |
|
I tried other simpler methods, but they became more complex and started to confuse me (Also, sometimes there result was not deterministic). The composite index seems simpler, with the only trade-off being that it requires extra space and may slightly increase insertion and update time. |
Cool. Feel free to open a PR with the migration to add the index. I will need to make a copy of the DB and test how long the migration takes with a large ArticlesCourses table, to make sure it's safe to migrate in production. |
I'll try to figure this one out too |
We enabled the slow query log feature on the
outreachdashboard
server to identify and optimize queries that take excessively long to execute. Currently, the log captures queries that run for more than one minute.The plan is to select a query, analyze it, optimize its performance, and submit a pull request with the improvements.
Done on PR #6260
AverageViewsImporter#update_outdated_average_views
queryThe text was updated successfully, but these errors were encountered: