New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
don't use rand() for choosing a random song for partymode #2046
Conversation
hum RANDOM() does not exist in MySQL |
Our db layer maps it to rand() for mysql. |
If it gets mapped to rand(), how does it improve anything? |
@bobo1on1: That mapping only applies to the use of RANDOM() / RAND() in SQL not in C++. |
@koying ping :) |
Oups, sorry, slipped through... Unfortunately, mysql uses "rand()", not "random()": http://dev.mysql.com/doc/refman/5.0/en/mathematical-functions.html#function_rand |
Read up :) - we already take care of that in the database layer. The question is whether this makes things unacceptably slow. Easiest test is partymode with a decent number of songs. The length to queue the next song (i.e. after the first song is over) in the list is of interest. |
Ok, so:
but still works without noticeable delay
|
Hmm, there doesn't seem to be anything wrong with the query, right? Mind running it in mysql directly and seeing if you get a bit more information from the error msg? EDIT: Hmm, why isn't RANDOM() -> RAND() being detected... |
Exactly ;) I didn't dig further, but I can if you want... |
Ah, I see the problem. The RANDOM() -> RAND() conversion is done only in vprepare, and we're using BuildSQL() which assumes pre-formatted. |
Ok, should work now :) |
Yep. working fine and no slowdowns :) |
don't use rand() for choosing a random song for partymode
Thanks :) |
Hi ! I'm wondering if the proposed patch also fixes the issue for music party mode, or just for video party mode ? |
It's not proposed, it's merged. Try any build from the last 10mo and you'll know whether or not it works. FYI. Commenting on github spams ~50 dev inboxs. Please keep support requests, like this, to the forums in the future. |
Ideally for Frodo. rand() typically returns a number between 0..32767, so for larger databases doesn't hit every possible row.
@koying: please test mysql. I have a feeling it will be quite slow, but not sure. Easy to test - just start partymode then skip a song.