I sort by randid() for my image gallery when I want random images for the homepage. It is VERY innefficient after you get a few hundred to a thousand records. I've got over 6000 records in that table. I need to find a better way to do it but I've been too lazy to work on it as of late.
Is there a difference in using ORDER BY RANDID() and ORDER BY NEWID() in MS SQL ?
Just a thought ; you might want to create an array once a day, filled with a random ordered list of the image ID's, and store that array in an application variable. Then, each time an image is retrieved, you get the first id from that array, and remove it from the array, and save the variable once again.
When the array contains less than let's say 5 ID's, recreate a new random filled array, and restart the entire circle.
In that way, your randomization occurs not on every image retrieval, but only every for instance 1000 retrievals.
This topic has been archived. Posting replies is no longer possible.