Brian Dunning wrote:
I am using a routine to find 50 random records in a large MySQL

how random does it need to be? if *psuedo* (nobody start on the
computer random is not really random argument - go watch "What the bleep
do we know?" instead) random is okay maybe you could define a list
of [funky/weird] ORDER BY subclauses and randomly
pick one to add to you sql query. by funky/weird I meaning using
multiple comlumn and direction indentifiers in unusual combinations.

to increase the psuedo randomness you could potentially use a randomized
FIRST declaration (or OFFSET in MySQL) - rather like you would with a
pagination routine. but thats dependent on the size of the constrained
resultset you get.

or alternatively, copy the data offline. run a "nice -19'd" script to
generate a batch of random 50 item sets. then let the online site
use the generated sets ... item [ids] in a set not found in the live DB could
be filled in by a query using the same where clause (but without the 
randomization)
and with a relevant FIRST, SKIP declaration for the 'fill', which
assuming your tables are indexed properly should be fast.

hope thats understandable.
rgds,
Jochem

database (about a million records) where I generate a list of 50 random unique ID's, and then use MySQL's "in" command to find them. I can't use "order by rand()" due to its performance hit.

But I have to take it one more step: I want to first limit my found set to those matching a different search criteria, and then find 50 of those.

Anyone? Can this be done all within MySQL, or is it going to require some humongo PHP arrays?


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to