MDL-41403 Backup: reduce memory usage when searching for courses / categories