Moodle Deleting single course is taking longer than 10 minutes

Moodle Deleting single course is taking longer than 10 minutes

by Neil Shah -
Number of replies: 1

Hello Everyone,

I am struggling with the course delete issue since last one month and I would really appreciate if I can get a proper guidance on this issue. I have created an application which is calling APIs given by Moodle to create and delete courses.  Upon the fresh installation of DB everything works fine. For example, I uploaded 50 courses and then tries to delete them using the function provided by Moodle (core_course_delete_courses) and it works fine. It takes 1 minute to delete the course but it works fine. But if I repeat this exercise again like 4-5 time then after that when I try to delete the course again using "core_course_delete_courses" function, it is taking more than 10 minutes. When I check the database I saw that it is executing like "102,884" sql statements which is quite huge for a single delete course. I am not sure what's going on. Any help will be highly appreciated.


NOTE: When the delete is working fine, I can see only 27000 sql statements but when delete is taking longer than 10 minutes, it is executing more than 100,000 sql statements.

Average of ratings: -
In reply to Neil Shah

Re: Moodle Deleting single course is taking longer than 10 minutes

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
I'm just commenting because nobody else has. It's very difficult to identify issues in somebody's custom code. Given that this doesn't happen in core Moodle you must have done something different. Don't overlook stuff like use of the cache and cache invalidation. A lot of that is critical in recent code.