Tim Starling wrote:
The efficient way to do it would be to enumerate the category members, saving the results to a table for later lookup. The entries in this special table could have an expiry time. Is that how you were planning on doing it?
I'm not sure I understand why you're coming up with a new scheme when there exists already a scheme for "Random Article".
"Random Article" works by having a page_random column in the pages table which just contains a random number.
In my mind, therefore, the obvious solution is to add a cl_random column to the categorylinks table. Then you select a random article from a category in the same way you select a random article from the entire site:
$sql = "SELECT page_id,page_title FROM $categorylinks, $page $use_index WHERE page_namespace=$namespace AND page_is_redirect=0 AND cl_random>$randstr AND cl_to=$category AND page_id=cl_from ORDER BY cl_random"; $sql = $db->limitResult($sql, 1, 0); $res = $db->query( $sql, $fname );
The index, of course, would be on (cl_to, cl_random).
Timwi