Re: SimpleLibraryViews plugin update increases library build time by a factor of 10

Michael Herger <slim-b/[email protected]> Fri, 20 May 2022 21:57:15 +0200
Newsgroups gmane.music.equipment.slimdevices.devel
Message-ID <[email protected]>
> Can you say what change causes the issue? Maybe you can go back in git 
> history to see what commit changed behaviour?

I believe that even if you don't hit the filesystem, you're going to 
test the same folders over and over again: if none of your files is 
found, you'd walk up the folder hierarchy. And you'd do this over and 
over again. Sure, by checking the cache (which could become pretty big 
in a large collection) you cut short. But still, you do this several times.

>  From a first quick look I was wondering whether it wouldn't be more 
> efficient to search for your your simple-library-views-* files, then map 
> these to the tracks, rather than the opposite?

I'd definitely recommend using File::Next or File::Find to get a list of 
library names with the folders they use. Then query the DB based on the 
folder. As you'd be able to insert based on the url that could be a 
pretty efficient SQL query. Something like

INSERT OR IGNORE INTO library_track (library, track)
	SELECT ?, tracks.id
	FROM tracks
	WHERE url like ?
	AND content_type NOT IN ("cpl", "src", "ssp", "dir")

where arguments are the library ID and the "file://path/to/folder%" 
(haven't tested this, but I assume you get the point).

Oh, and you got quite a few "libary" instead of "library" in your readme 
:-).