Sorry to pine users...
Taking the SQL query used in Special:Randompage from CVS and modifying it very slightly...
SELECT cur_id,cur_title,cur_random FROM cur USE INDEX (cur_random) WHERE cur_namespace=0 AND cur_is_redirect=0 AND cur_random>RAND() ORDER BY cur_random LIMIT 20
returns...
cur_id cur_title cur_random 124125 Pierce,_Nebraska 0.0030205277754185 205997 Wagh_el_Birket 0.00385735184313483 120605 Custer_Township,_Minnesota 0.00416424684614339 131375 Lorane,_Pennsylvania 0.00439120363853053 150887 Columbiana,_Ohio 0.00589350611520326 53913 Castle_Rock 0.00614019670164231 10438 Komyo 0.00616735406794339 131027 Newberg,_Oregon 0.00645017624502087 120060 Hartland_Township,_Minnesota 0.00903007575220435 126590 Osceola,_New_York 0.00905275718220766
It doesn't always return the same articles, but they're always very low-numbered. I don't know about you, but I would call that a MySQL bug. This is good because it means Brion has already fixed the problem.
May I make a suggestion, while we're on the topic? How about changing the query to:
SELECT cur_id,cur_title,cur_random FROM cur USE INDEX (cur_random) WHERE cur_namespace=0 AND cur_is_redirect=0 AND cur_random>{$rand} AND cur_user<>3903 AND cur_user<>6120 ORDER BY cur_random LIMIT 20
which will skip anything last edited by Ram-Man or Rambot. Like Daniel Mikkelsen said, the most important function for Special:Randompage is to impress passers-by. We should rig it any way we can to make Wikipedia look better.
-- Tim Starling
Tim Starling schrieb:
Taking the SQL query used in Special:Randompage from CVS and modifying it very slightly...
SELECT cur_id,cur_title,cur_random FROM cur USE INDEX (cur_random) WHERE cur_namespace=0 AND cur_is_redirect=0 AND cur_random>RAND() ORDER BY cur_random LIMIT 20
I guess that's why this doesn't work: MySQL processes the query in the following order:
1. Fetching 2. Ordering 3. Limiting
1. MySQL fetches rows from the table until there ist no more row with cur_random greater than the recently generated RAND() (it generates a new RAND() on every fetch). This should return on avarage half of the rows from the table. 2. MySQL orders the fetched rows by cur_random in ascending order. 3. MySQL returns the 20 rows with the lowest cur_random from the subset.
-- WeißNix
I see that you techies discussing how to tweak Random Page behaviour, but Polish Wikipedia suffers a bit: when Random Page is pressed the following message appears. Other main 'pedias do not report any error. Can you correct that quickly? Thanks in advance
Regards Youandme
--------------------------------------------------------
Wystšpił błšd składni w zapytaniu do bazy danych. Mogło to być spowodowane przez złe sformułowanie zapytania (zobacz Przeszukiwanie Wikipedii) albo przez błšd w oprogramowaniu. Ostatnie, nieudane zapytanie to:
SELECT cur_id,cur_title FROM cur USE INDEX (cur_random) WHERE cur_namespace=0 AND cur_is_redirect=0 AND cur_random>0,172539821906 ORDER BY cur_random LIMIT 1
wysłane przez funkcję "wfSpecialRandompage". MySQL zgłosił błšd "1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '172539821906 ORDER BY cur_random LIMIT 1' at line 4".
On Fri, 6 Jun 2003, Youandme wrote: (on Polish wiki)
SELECT cur_id,cur_title FROM cur USE INDEX (cur_random) WHERE
cur_namespace=0 AND cur_is_redirect=0 AND cur_random>0,172539821906
Ah, I do so love PHP's transparent support for localization. :P
I'll see if I can work around that...
-- brion vibber (brion @ pobox.com)
On Fri, 6 Jun 2003, Brion Vibber wrote:
On Fri, 6 Jun 2003, Youandme wrote: (on Polish wiki)
SELECT cur_id,cur_title FROM cur USE INDEX (cur_random) WHERE
cur_namespace=0 AND cur_is_redirect=0 AND cur_random>0,172539821906
Ah, I do so love PHP's transparent support for localization. :P
I'll see if I can work around that...
I've switched from variable interpolation with an implicit float->string conversion to using the number_format() function, where I can explicitly set the decimal separator to "." to keep MySQL from choking when set in a locale with "," as the decimal separator.
Seems happy so far...
-- brion vibber (brion @ pobox.com)
On 6 Jun 2003 at 11:42, Brion Vibber wrote:
I've switched from variable interpolation with an implicit float->string conversion to using the number_format() function, where I can explicitly set the decimal separator to "." to keep MySQL from choking when set in a locale with "," as the decimal separator.
Seems happy so far...
:) As happy as me and others Thank you very much Youandme
wikitech-l@lists.wikimedia.org