Well no, you wouldn't get it in the same order, I believe the idea of the page_random is:

[[A]] has page_random = 4
[[B]] has page_random = 2
[[C]] has page_random = 6

We grab the highest page random:
[[C]] is returned, resetting page_random, now [[C]] has page_random = 3

[[A]] = 4
[[B]] = 2
[[C]] = 3

Another query:
[[A]] is returned, resetting page_random = 1

[[A]] = 1
[[B]] = 2
[[C]] = 3

And so on, it gets even more random as you get more articles.

Now if you were to extend that into multiple values, rather than just grabbing the highest. You would use "ORDER BY page_random DESC LIMIT ..count..". That way you are getting a similar result to if you queried for a random page a bunch of times, because the order by sorts them in the order you would recieve them. It's just a bonus to that since it's also in a single query, there is no possible way for a page to be returned more than once despite all randomness. And when you update the page_random, you'll update all the rows you grabbed instead of just one.

~Daniel Friesen(Dantman, Nadir-Seen-Fire) of:
-The Nadir-Point Group (http://nadir-point.com)
--It's Wiki-Tools subgroup (http://wiki-tools.com)
--The ElectronicMe project (http://electronic-me.org)
--Games-G.P.S. (http://ggps.org)
-And Wikia ACG on Wikia.com (http://wikia.com/wiki/Wikia_ACG)
--Animepedia (http://anime.wikia.com)
--Narutopedia (http://naruto.wikia.com)

Markus Krötzsch wrote:
On Dienstag, 5. August 2008, Daniel Friesen wrote:
MediaWiki makes use of a `page_random` field for the [[Special:Random]]
page.
I'm assuming that it grabs the highest value from that index, then when
viewed regenerates the page_random value there in some way.

It would be worth it to look over how MediaWiki deals with random pages,
and either integrate with it or do random queries in a similar way.

Right, that works and we could do something similar. The point is that MediaWiki returns only a single random page each time. Hence the order of pages is not a problem. If you would return more than one result, as in SMW, then you would always retrieve results in the same order; certain results can never appear in one result set in spite of all randomness.

On the other hand, retrieving arbitrary results from unconnected places throughout the data set clearly thwarts fundamental methods of database optimisation. True randomness would mean that the DB cannot be prepared for it, has no index to use, and must read results from all over the (physical) disk. It is clear that this fails as soon as the DB table size exceeds the available memory. So maybe a semi-random method as in MW would have to be accepted.

Regards,

Markus

~Daniel Friesen(Dantman, Nadir-Seen-Fire) of:
-The Nadir-Point Group (http://nadir-point.com)
--It's Wiki-Tools subgroup (http://wiki-tools.com)
--The ElectronicMe project (http://electronic-me.org)
--Games-G.P.S. (http://ggps.org)
-And Wikia ACG on Wikia.com (http://wikia.com/wiki/Wikia_ACG)
--Animepedia (http://anime.wikia.com)
--Narutopedia (http://naruto.wikia.com)

Markus Krötzsch wrote:
On Montag, 4. August 2008, Asheesh Laroia wrote:
On Fri, 25 Jul 2008, Steren wrote:
hi,
I wrote yesterday a small patch for SMW. It allows to sort query
results randomly.
Creative Commons needed this feature for its Casestudies project.
[Further details snipped]

Dear SMW devs,

Can this patch be included in the SMW svn?

That would be lovely.  If there is a reason it can't, let's see if it
can be worked out!
Well, I guess it can be included. Of course it is clear that this just
cannot perform very well, so there should probably be a switch to enable
it only if desired. It might be good to have a MediaZilla entry for that,
so I do not forget.

One could also think about some faster not-so-random solution as a
fallback for larger sites.

-- Markus

-- Asheesh.
------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's
challenge Build the coolest Linux based applications with Moblin SDK &
win great prizes Grand prize is a trip for two to an Open Source event
anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
------------------------------------------------------------------------

_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel



------------------------------------------------------------------------

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
------------------------------------------------------------------------

_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Semediawiki-devel mailing list
Semediawiki-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel

Reply via email to