The use of RAND() in a SELECT statement is slow if the number of rows grows (especially if you have 100,000+ rows!) This is because the database system will go through many rows before it hits the one that it will pick (it has to because there isn't an index it can use to query a random row).
A site that would have that many quotes would also have quite many users hitting the site all the time. This means the use of an identifier that's also available in an index table will save a lot of query time. And since there would be so many users, showing the quotes in order would show up as random to 99.9% of the users.
So the new feature proposed is:
1. Add a new option "Cycle Quotes" which when selected generates:
2. Use a variable to save the current quote index
3. Retrieve the quote with that specified index (if some quotes can be deleted and thus indexes missing, use $id >= quotes.qid and a limit of 1, this is still very fast because it still makes use of the index table to find the closest identifier)
4. Add 1 to the quote index and save it back in the variable (if some indexes are missing, make sure to use the last quote loaded index + 1)
If you think you need that feature, let us know.
Thank you.
Alexis Wilke
Comments
Comment #1
nancydruI've been looking at this and I'm just not sure how to do this without a bigger performance hit than we're trying to solve.
Comment #2
AlexisWilke commentedNancy,
No problem. That was just a comment. 8-}
Thank you for having a look at it.
Alexis
Comment #3
nancydruOkay