Skip to content
Draft
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion SQL/SQLite/schema_optimize.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- This is done here as it is faster to do in sql than in the server.
--

DELETE FROM scanned_pics;
--DELETE FROM scanned_pics; ### Removed temporarily for debugging

-- XXX This appears to not be needed anymore as contributors are properly
-- removed by the new scanner
Expand Down
18 changes: 15 additions & 3 deletions SQL/SQLite/schema_scanner.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ CREATE INDEX scannedUrlIndex ON scanned_files (url);

DROP TABLE IF EXISTS scanned_pics;
CREATE TABLE scanned_pics (
url text NOT NULL,
folder text,
full_path text NOT NULL,
timestamp int(10),
filesize int(10)
filesize int(10),
coverid char(8),
status char(1) CHECK (status IN ('D', 'E', 'N'))
-- D = image deleted (ie used in the database (tracks.cover) but no longer existing on disk)
-- E = an existing image present in tracks.cover
-- N = a new image (eg on disk but not used in tracks.cover - might actually have been on disk before, but passed over in a previous scan)
-- NULL = we'll set status 'E' to NULL if after n&c music files have been processed the image is still being used.
-- This improves performance as we'll only process the tracks if there's also a N(ew) image
);
CREATE INDEX scannedPicUrlIndex ON scanned_pics (url);
CREATE INDEX scannedPicUrlIndex ON scanned_pics (full_path);
CREATE INDEX scannedPicDirIndex ON scanned_pics (folder);
create index scannedPicStatusidx on scanned_pics(status);

CREATE INDEX IF NOT EXISTS trackscoveridx ON tracks(cover);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add this to one of the versioned files, too? If it's only used in the scanner (for now) we can probably get away adding it to the latest existing up files, avoiding another full wipe & rescan.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That reminds me, I changed the INSERT to check tracks using coverid rather than cover, in case the user has updated an image without changing the file name. So I don't think this index is required any more.

https://github.com/darrell-k/slimserver/blob/4da574ef3d256ac970f2baeb026895dd28f535b8/Slim/Utils/Scanner/Local/Async.pm#L50-L57

2 changes: 1 addition & 1 deletion SQL/mysql/schema_optimize.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
-- This is done here as it is faster to do in sql than in the server.
--

DELETE FROM scanned_pics;
--DELETE FROM scanned_pics; ### Removed temporarily for debugging

-- XXX This appears to not be needed anymore as contributors are properly
-- removed by the new scanner
Expand Down
18 changes: 15 additions & 3 deletions SQL/mysql/schema_scanner.sql
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,20 @@ CREATE INDEX scannedUrlIndex ON scanned_files (url);

DROP TABLE IF EXISTS scanned_pics;
CREATE TABLE scanned_pics (
url text NOT NULL COLLATE NOCASE, -- URL must be case insensitive, or we might duplicate tracks if the filename changes case only (https://github.com/LMS-Community/slimserver/issues/705#issuecomment-1026229542)
folder text,
full_path text NOT NULL,
timestamp int(10),
filesize int(10)
filesize int(10),
coverid char(8),
status char(1) CHECK (status IN ('D', 'E', 'N'))
-- D = image deleted (ie used in the database (tracks.cover) but no longer existing on disk)
-- E = an existing image present in tracks.cover
-- N = a new image (eg on disk but not used in tracks.cover - might actually have been on disk before, but passed over in a previous scan)
-- NULL = we'll set status 'E' to NULL if after n&c music files have been processed the image is still being used.
-- This improves performance as we'll only process the tracks if there's also a N(ew) image
);
CREATE INDEX scannedPicUrlIndex ON scanned_pics (url);
CREATE INDEX scannedPicUrlIndex ON scanned_pics (full_path);
CREATE INDEX scannedPicDirIndex ON scanned_pics (folder);
create index scannedPicStatusidx on scanned_pics(status);

CREATE INDEX IF NOT EXISTS trackscoveridx ON tracks(cover);
Loading