| From: Tue Tnning | Date Sent: 2003-02-05 11:38:55 |
| Subject: RAND() Problems in mysql version 3.23.54 and 3.23.55 (linux) | To: MySQL Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
Hey,
I have discovered a strange error in the mysql versions mentioned in subj.
Example.
A table with 10 entries ...i want to draw 3 randomly
=> "select fieldName from tableName order by RAND() limit 3"
this have worked for the last year or so.....but after upgrading our redhat
7.2 with mysql version 3.23.54 it stopped to work. It always chooses the
same 3 entires.
using a Seed doesnt make it perfect either (i know that the manual says that
RAND() isnt perfect - but now it doesnt work at all).
A quick search on google says me that im not the only one having the
problem. I can also see on some Danish messageboards that other have the
same problems with the new version.
So my question is .....What to do ?
I cant imagine that you have removed the functionality of RAND from mysql
again ?
i know its only been in there since early ~3.23....
I work professionally as a webdevolper (CEO of a firm) and we need to find a
solution to this problem badly.
I hope you can guide me to a solution. Cause i would hate to change all the
sql calls in the projects we have coded the last 1 year.... and it would be
nice to know if we would be able to use RAND() in the future.
Ohh, yeah - we code in PHP......and i have talked today with 3 other
webdevelopment companies that have been struggeling with the same error
after upgrading.
Med venlig hilsen / Best regards
Tue Tnning
--------------------
AT-Orbital I/S
Helsingforsgade 27, 1
DK-8200 Aarhus N
Denmark
Phone +45 8942 5860
Web www.atorbital.com
----------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <mysql-thread131699@[Protected]>
To unsubscribe, e-mail <mysql-unsubscribe-archiver=blueworld.com@[Protected]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
| From: Aman Raheja | Date Sent: 2003-02-06 15:03:47 |
| Subject: Re: RAND() Problems in mysql version 3.23.54 and 3.23.55 (linux) | To: MySQL Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
HINT:
I have used PERL to generate random numbers and then do a SELECT on the
auto_increment field in the mysql table, thus generating random picks from
my tables;
I'll be glad to bet informed of better ways around, though :)
Thanks
Aman Raheja
AGF Inc.
----- Original Message -----
From: "Tue Tnning" <tt@[Protected]>
To: <mysql@[Protected]>
Sent: Wednesday, February 05, 2003 1:38 PM
Subject: RAND() Problems in mysql version 3.23.54 and 3.23.55 (linux)
> Hey,
>
> I have discovered a strange error in the mysql versions mentioned in subj.
>
> Example.
> A table with 10 entries ...i want to draw 3 randomly
> => "select fieldName from tableName order by RAND() limit 3"
>
> this have worked for the last year or so.....but after upgrading our
redhat
> 7.2 with mysql version 3.23.54 it stopped to work. It always chooses the
> same 3 entires.
>
> using a Seed doesnt make it perfect either (i know that the manual says
that
> RAND() isnt perfect - but now it doesnt work at all).
>
> A quick search on google says me that im not the only one having the
> problem. I can also see on some Danish messageboards that other have the
> same problems with the new version.
>
> So my question is .....What to do ?
> I cant imagine that you have removed the functionality of RAND from mysql
> again ?
> i know its only been in there since early ~3.23....
>
> I work professionally as a webdevolper (CEO of a firm) and we need to find
a
> solution to this problem badly.
>
> I hope you can guide me to a solution. Cause i would hate to change all
the
> sql calls in the projects we have coded the last 1 year.... and it would
be
> nice to know if we would be able to use RAND() in the future.
>
> Ohh, yeah - we code in PHP......and i have talked today with 3 other
> webdevelopment companies that have been struggeling with the same error
> after upgrading.
>
> Med venlig hilsen / Best regards
>
> Tue Tnning
> --------------------
> AT-Orbital I/S
> Helsingforsgade 27, 1
> DK-8200 Aarhus N
> Denmark
> Phone +45 8942 5860
> Web www.atorbital.com
>
>
>
> ----------------------------------------------------------
> Before posting, please check:
> http://www.mysql.com/manual.php (the manual)
> http://lists.mysql.com/ (the list archive)
>
> To request this thread, e-mail <mysql-thread131699@[Protected]>
> To unsubscribe, e-mail
<mysql-unsubscribe-amanmysql=hotmail.com@[Protected]>
> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
>
----------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <mysql-thread131791@[Protected]>
To unsubscribe, e-mail <mysql-unsubscribe-archiver=blueworld.com@[Protected]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
| From: Sergei Golubchik | Date Sent: 2003-02-11 14:15:25 |
| Subject: Re: RAND() Problems in mysql version 3.23.54 and 3.23.55 (linux) | To: MySQL Talk |
| Navigation: First Message | Previous Message | Next Message | Last Message | |
Hi!
On Feb 05, Tue Tnning wrote:
> Hey,
>
> I have discovered a strange error in the mysql versions mentioned in subj.
>
> Example.
> A table with 10 entries ...i want to draw 3 randomly
> => "select fieldName from tableName order by RAND() limit 3"
>
> this have worked for the last year or so.....but after upgrading our redhat
> 7.2 with mysql version 3.23.54 it stopped to work. It always chooses the
> same 3 entires.
try simply
mysql -BNe 'select rand(), rand(), rand(), rand()'
mysql -BNe 'select rand(), rand(), rand(), rand()'
mysql -BNe 'select rand(), rand(), rand(), rand()'
to see the problem.
RAND() initialization for new connection isn't very random,
so first few rand() values differ only slightly.
It was fixed in 4.0. I will backport the fix to 3.23.
You can either upgrade to MySQL 4.0, or wait till next 3.23 release,
or use a simple workaround: run
do benchmark(10,rand());
just after establishing connection - before first SELECT.
> Ohh, yeah - we code in PHP......and i have talked today with 3 other
> webdevelopment companies that have been struggeling with the same error
> after upgrading.
Easy - no need to struggling, just submit a bugreport - the bug will be
fixed at once :)
Regards,
Sergei
--
MySQL Development Team
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sergei Golubchik <serg@[Protected]>
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, http://www.mysql.com/
/_/ /_/\_, /___/\___\_\___/ Osnabrueck, Germany
<___/
----------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <mysql-thread132143@[Protected]>
To unsubscribe, e-mail <mysql-unsubscribe-archiver=blueworld.com@[Protected]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php