-
Notifications
You must be signed in to change notification settings - Fork 72
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
generate_status_report performance - SQL improvements #596
Comments
Hi, We've come up with a SQL query using Common Table Elements approach. This was meant to help make the queries easier to read / understand but in practice trials these perform much faster. As well, the MySQL server doesn't exhaust resources running these, even when using a lower instance class. Downside, MySQL 5.7 supposedly doesn't support CTE / the WITH clause, so I guess this would require a new branch for Moodle 4.2 where MySQL 8 is the minimum. For location = DUPLICATED, EXTERNAL, ERROR
For location = LOCAL
For location = ORPHANED
|
We've trialled these queries on various Moodle databases of various sizes on MySQL 8 and on PostgreSQL 14. In all cases they return the same numbers as their current counterparts. For all cases except location = LOCAL, they execute much faster. For case of location = LOCAL there is not as much improvement in speed compared to its current counterpart, but it's worth noting that even with a lower AWS instance class (meaning less CPU and less memory) the new query returns whereas the old one causes the issues described earlier. |
@JoshAudette rather than code in a comment can you turn this into a PR please? |
Hi @brendanheywood PR is ready, although these SQL queries use the I think we may need a base branch |
…report_sql_tweaks Issue #596: SQL change with some performance / resource improvements
Issue:
The
\tool_objectfs\task\generate_status_report
task can be quite slow and costly in terms of database resources.Recently we have experienced SQL queries failing on MySQL with a message indicating temporary storage space full. On reconfiguring MySQL to favour memory (
temptable_max_ram
tweak) we saw the query succeed for awhile, but lately the MySQL database exhausts memory causing it to restart.We have had a look at changing the SQL queries used by the report.
See also: #572
The text was updated successfully, but these errors were encountered: