Do not try to optimize when there are too few files, it seems to bring more drawbacks than benefits
This commit is contained in:
@@ -321,7 +321,7 @@ namespace lms::scanner
|
||||
|
||||
bool ScanStepAssociateArtistImages::needProcess(const ScanContext& context) const
|
||||
{
|
||||
if (context.stats.nbChanges() > 0)
|
||||
if (context.stats.getChangesCount() > 0)
|
||||
return true;
|
||||
|
||||
if (getLastScanSettings() && getLastScanSettings()->artistImageFallbackToRelease != _settings.artistImageFallbackToRelease)
|
||||
|
||||
@@ -145,7 +145,7 @@ namespace lms::scanner
|
||||
|
||||
bool ScanStepAssociateExternalLyrics::needProcess(const ScanContext& context) const
|
||||
{
|
||||
if (context.stats.nbChanges() > 0)
|
||||
if (context.stats.getChangesCount() > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
|
||||
@@ -251,7 +251,7 @@ namespace lms::scanner
|
||||
|
||||
bool ScanStepAssociatePlayListTracks::needProcess(const ScanContext& context) const
|
||||
{
|
||||
if (context.stats.nbChanges() > 0)
|
||||
if (context.stats.getChangesCount() > 0)
|
||||
return true;
|
||||
|
||||
if (getLastScanSettings() && getLastScanSettings()->skipSingleReleasePlayLists != _settings.skipSingleReleasePlayLists)
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace lms::scanner
|
||||
|
||||
bool ScanStepAssociateReleaseImages::needProcess(const ScanContext& context) const
|
||||
{
|
||||
return context.stats.nbChanges() > 0;
|
||||
return context.stats.getChangesCount() > 0;
|
||||
}
|
||||
|
||||
void ScanStepAssociateReleaseImages::process(ScanContext& context)
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace lms::scanner
|
||||
|
||||
bool ScanStepAssociateTrackImages::needProcess(const ScanContext& context) const
|
||||
{
|
||||
return context.stats.nbChanges() > 0;
|
||||
return context.stats.getChangesCount() > 0;
|
||||
}
|
||||
|
||||
void ScanStepAssociateTrackImages::process(ScanContext& context)
|
||||
|
||||
@@ -194,12 +194,7 @@ namespace lms::scanner
|
||||
|
||||
{
|
||||
auto transaction{ session.createReadTransaction() };
|
||||
context.currentStepStats.totalElems = 0;
|
||||
context.currentStepStats.totalElems += db::Track::getCount(session);
|
||||
context.currentStepStats.totalElems += db::Image::getCount(session);
|
||||
context.currentStepStats.totalElems += db::TrackLyrics::getExternalLyricsCount(session);
|
||||
context.currentStepStats.totalElems += db::PlayListFile::getCount(session);
|
||||
context.currentStepStats.totalElems += db::ArtistInfo::getCount(session);
|
||||
context.currentStepStats.totalElems = session.getTotalFilesCount();
|
||||
}
|
||||
LMS_LOG(DBUPDATER, DEBUG, context.currentStepStats.totalElems << " files to be checked...");
|
||||
|
||||
|
||||
@@ -29,10 +29,7 @@ namespace lms::scanner
|
||||
{
|
||||
bool ScanStepComputeClusterStats::needProcess(const ScanContext& context) const
|
||||
{
|
||||
if (context.stats.nbChanges() > 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
return context.stats.getChangesCount() > 0;
|
||||
}
|
||||
|
||||
void ScanStepComputeClusterStats::process(ScanContext& context)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user