The datalib function get_my_courses returns all courses that the current user has permission to view. For example, for an admin it returns every course on the site. This can cause performance and also interface problems.
In the past for a quick fix I added a limit parameter which you can use to resolve performance problems (calling the function as-is for admin requires many thousand database queries if you have thousands of courses). However the real issue is that usually when this function is called, you actually want the enrolled courses i.e. courses which people have an actual role in.
I would suggest making get_my_courses deprecated and creating two functions get_my_permitted_courses (which is the same as current, and is what get_my_courses calls) and get_my_enrolled_courses. get_my_enrolled_courses would basically restrict the list to include only those courses you have a specific role in (as well as having the course:view permission).
(note, eloy asked me to file this bug! blame him!