![](https://mi.cx/wp-content/uploads/2024/07/snailSQL.png)
MyTutor is a UK-based online platform dedicated to one-to-one learning. Through a curated community of tutors, they provide personalised learning experiences to their customers.
Some of the SQL queries in the MyTutor application were taking a very long time to run. We already had the MySQL slow query log logging them to AWS CloudWatch, but we found they were left unnoticed there.
I wrote a Python script to pull the slow query log from AWS CloudWatch, remove any data from the query, and assign a score based on time taken and occurrence. I then sorted them by this score, with the worst offenders first, and posted the results to a Slack channel monitored by the development teams.
The code is run each morning via a GitHub Action cron job.
This allowed the developers to focus on the most troublesome queries and get them under control, improving the application’s performance and lowering AWS costs.