Optimize the `FilesModel` queries