View Issue Details

IDProjectCategoryView StatusLast Update
0003089MMW v4Playerpublic2007-06-12 14:27
Reporterjiri Assigned To 
PriorityurgentSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version3.0 
Fixed in Version3.0 
Summary0003089: Speed problems of Auto-DJ
DescriptionAuto-DJ has problem in several cases:

1. If none of the tracks in Library is accessible - in such a case it attempts to add tracks, probably endlessly.
2. If there are _many_ tracks in Library, Auto-DJ is very slow. The main reason probably is that FillSongListRandomSong() uses ORDER BY on all tracks.

Both problems can be easily reproduced using a big DB (~107k tracks) from our user that's uploaded to FTP, BigDB folder.
Additional InformationSuggested solution:
2.
a. Instead of using 'ORDER BY sin(songs.id + filelength*(1+%.7f) + filemodified*(1+%.7f) + %.7f)' which is there since MS Access times, we could use 'ORDER BY random(*)' that's available in SQLite. However, this probably won't help much and so I'd rather prefer
b. Use a solution I proposed in SQLite mailing list, i.e. in order to get a random record from a table, the following can be used:

SELECT * FROM Table LIMIT 1 OFFSET round((CAST(random(*) as
float)/(9223372036854775807)+1)/2*(SELECT COUNT(*) FROM Table))

Some tweaks might be needed, it can e.g. be divided into two queries, some error handling might be needed, filters have to be taken into account, etc.
TagsNo tags attached.
Fixed in build1038

Activities

Ludek

2007-06-06 13:08

developer   ~0009253

Last edited: 2007-06-06 13:12

Note: Only 1. can be easily reproduced using the big DB from BigDB folder, because the DB is full of deadlines and Auto-DJ doesn't add a deadlines at all.

1. It is fixed

2. I have resolved it another (my own way) which is the fastest.
Tested on my DB with 5500 songs and here are a test results for one song adding:
- Original solution takes 1 s
- Using of 2a ('ORDER BY random(*)') takes 1 s
- Using of 2a with 'LIMIT' clause takes 0,3 s
- Using of 2b takes 0,05 s.
- Using of my solution takes 0,0024 s

So the my solution is the fastest and in addition 2b would not work right because COUNT(*) could not match the top ID of the table which has to be used in this case.

jiri

2007-06-06 14:36

administrator   ~0009254

As discussed over IM, 2b. will be implemented and will be used even when some filters are defined.

Ludek

2007-06-06 16:03

developer   ~0009262

Fixed this according to Jiri's 2b suggestion/solution

rusty

2007-06-12 14:27

administrator   ~0009345

Verified 1039.