Importing playlists/crates is really slow

Bug #1171235 reported by Steven Boswell
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Mixxx
Fix Released
Medium
Steven Boswell

Bug Description

The first time I imported an external playlist (i.e. an .m3u file), I noticed that it was doing a database commit for every track. This is really inefficient. The enclosed patch provides a simple fix for this.

It turns out that CrateFeature::slotImportPlaylist() (and BasePlaylistFeature::slotImportPlaylist()) were calling their corresponding TableModel's addTrack() method in a loop, instead of calling addTracks(). This patch fixes that problem.

Related branches

Revision history for this message
Steven Boswell (ulatekh) wrote :
Revision history for this message
Steven Boswell (ulatekh) wrote :

I only seem to be able to attach one patch per comment, so here's the other half of the fix.

TrackDAO::addTracks() was trying to add each track in the playlist to the database. If most of the tracks are in the database already, this is a big waste of time.

I've rewritten the method so that it uses SQL queries to reduce the amount of work that needs to be done. Now it only tries to add tracks that were not already in the database.

On an imported playlist with ~1900 entries, this reduced the time needed to import from 5 minutes to 2 seconds.

Max Linke (max-linke)
Changed in mixxx:
status: New → In Progress
assignee: nobody → Steven Boswell (ulatekh)
Revision history for this message
Max Linke (max-linke) wrote :

thanks, commited

Changed in mixxx:
status: In Progress → Fix Committed
importance: Undecided → Medium
milestone: none → 1.11.0
Revision history for this message
Steven Boswell (ulatekh) wrote :

ACK! There's a nasty bug in my code! The source of it is a bad constraint in res/schema.xml, which this patch fixes. It also adds some comments about how the problem originated and what could have been done to avoid it.

Please apply this patch!

Luckily, the errors introduced by the old code can be fixed simply by deleting any playlists/crates imported since getting that change, and re-importing them.

Revision history for this message
RJ Skerry-Ryan (rryan) wrote :

Thanks -- added the fix to TrackDAO -- I'll add the schema upgrade to 1.11.1.
I'm pretty sure it's a no-op to do the upgrade but better safe than sorry :).

RJ Skerry-Ryan (rryan)
Changed in mixxx:
status: Fix Committed → Fix Released
Revision history for this message
Swiftb0y (swiftb0y) wrote :

Mixxx now uses GitHub for bug tracking. This bug has been migrated to:
https://github.com/mixxxdj/mixxx/issues/6997

lock status: Metadata changes locked and limited to project staff
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.