Do not try to optimize when there are too few files, it seems to bring more drawbacks than benefits

This commit is contained in:
emeric
2025-07-18 19:29:08 +02:00
parent f64a93b5b6
commit f51ceb933e
20 changed files with 116 additions and 52 deletions
@@ -32,8 +32,13 @@ namespace lms::scanner
if (context.scanOptions.forceOptimize)
return true;
if (context.stats.nbChanges() > (context.stats.nbFiles() / 10))
// Don't optimize if there are too few files: it may lead to some indexes not being used
// and will drastically slow down the scan process when adding more files later
if (context.stats.getChangesCount() > (context.stats.getTotalFileCount() / 5)
&& context.stats.getTotalFileCount() >= 1'000)
{
return true;
}
return false;
}