Commit abc23789 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

Album: Index title

This will avoid a full table scan for each new track we analyze
parent 0a1dc92d
Pipeline #238226 passed with stage
in 10 minutes and 54 seconds
......@@ -576,6 +576,8 @@ void Album::createIndexes( sqlite::Connection* dbConnection )
index( Indexes::ArtistId, Settings::DbModelVersion ) );
sqlite::Tools::executeRequest( dbConnection,
index( Indexes::NbTracks, Settings::DbModelVersion ) );
sqlite::Tools::executeRequest( dbConnection,
index( Indexes::Title, Settings::DbModelVersion ) );
}
std::string Album::schema( const std::string& tableName, uint32_t dbModel )
......@@ -827,6 +829,10 @@ std::string Album::index( Indexes index, uint32_t dbModel )
assert( dbModel >= 34 );
return "CREATE INDEX " + indexName( index, dbModel ) + " ON " +
Table::Name + "(nb_tracks, is_present)";
case Indexes::Title:
assert( dbModel >= 37 );
return "CREATE INDEX " + indexName( index, dbModel ) + " ON " +
Table::Name + "(title)";
}
return "<invalid request>";
}
......@@ -843,6 +849,9 @@ std::string Album::indexName( Album::Indexes index, uint32_t dbModel )
case Indexes::NbTracks:
assert( dbModel >= 34 );
return "album_nb_tracks_idx";
case Indexes::Title:
assert( dbModel >= 37 );
return "album_title_idx";
}
return "<invalid request>";
}
......
......@@ -65,6 +65,7 @@ class Album : public IAlbum, public DatabaseHelpers<Album>
{
ArtistId,
NbTracks,
Title,
};
Album( MediaLibraryPtr ml, sqlite::Row& row );
......
......@@ -140,3 +140,5 @@ Album::trigger( Album::Triggers::UpdateOnMediaAlbumIdChange, 37 ),
Show::trigger( Show::Triggers::UpdateIsPresent, 37 ),
Artist::trigger( Artist::Triggers::HasTrackPresent, 37 ),
Label::trigger( Label::Triggers::DeleteMediaLabel, 37 ),
Album::index( Album::Indexes::Title, 37 ),
......@@ -106,6 +106,7 @@ namespace
const std::vector<const char*> expectedIndexes{
"album_artist_id_idx",
"album_nb_tracks_idx",
"album_title_idx",
"artist_media_rel_artist_id_idx",
"audio_track_attached_file_idx",
"audio_track_media_idx",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment