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.