nextcloud / files_antivirus

👾 Antivirus app for Nextcloud Files
https://apps.nextcloud.com/apps/files_antivirus
GNU Affero General Public License v3.0
85 stars 36 forks source link

Optimize slow DB query #213

Closed SirTediousOfFoo closed 2 years ago

SirTediousOfFoo commented 2 years ago

As per https://github.com/nextcloud/files_antivirus/issues/177#issuecomment-742831423 the query using NOT IN has been replaced with a LEFT JOIN

Looks functional after having it run on a 200+ user server for a while, it got rid of the horrendous 20 hour hang caused by running the query on PostgreSQL databases and it shouldn't be any slower on MariaDB/MySQL.

I'm not really a PHP dev so excuse me if there's anything really wrong with this change :)

icewind1991 commented 2 years ago

Thanks for looking into this.

Seems like you mixed up the "unscanned" and "outdated" logic, fixed it and added some tests for both methods.