catalyst / moodle-local_smartmedia

Moodle LMS Smartmedia local plugin
Other
7 stars 5 forks source link

Add extra filter to SQL query to get media files in order to reduce records loaded in memory #220

Open andrewmadden opened 1 year ago

andrewmadden commented 1 year ago

There are cases when the total number of files fetched using the current get_media_files method can number 100,000 plus. Loading this amount of records into memory can heavily impact page load times.

The solution is to add an additional filter for the filepath so only the records relating for the file being loaded, is loaded into memory. This should never exceed a dozen.

The SQL is still able to take advantage of the existing index made up of fields contextid, component, filearea, itemid.