Comparing specific fields of documents in database with local state and get the offset

Hi,
I am currently trying to compare locally stored files with files in the database.

I would like to check if checksums of files have changed and if they did, return those.

A file has a file_path, checksum, content and some other fields.

At current query gets pretty big because it’s an or statement for every file and it takes over a minutes for 17000 files. Is there a more performant way to achieve this?

self._get_collection(<NAME>).find(
            {
                "$and": [
                    {"project_id": <ID>},
                    {
                        "$or": [
                            {
                                "file_path": file_path,
                                "checksum": {"$ne": checksum},
                            }
                            for file_path checksum in existing
                        ]
                    },
                ]
            },
            {"content": 0},
        )