Subject | Randomly returning records |
---|---|
Author | Ed Dressel |
Post date | 2006-05-18T13:29:08Z |
I need to be able to return a random selection of records from a
table. Each record needs be weighted in how often it gets returned
compared to the other records. (What is happening is that I need to
randomly return customer quotes to be displayed on a web site).
Every method I've thought of seems pretty slow--any fast way of doing
this? I can speed it up by having the sum of the weighted values in a
different table (updated by triggers) but then selecting the records
will require a bit of work--first selecting the IDs and weighting and
then randomly selecting quotes.
Any thoughts on a fast method for doing this?
Thanks
Ed Dressel
table. Each record needs be weighted in how often it gets returned
compared to the other records. (What is happening is that I need to
randomly return customer quotes to be displayed on a web site).
Every method I've thought of seems pretty slow--any fast way of doing
this? I can speed it up by having the sum of the weighted values in a
different table (updated by triggers) but then selecting the records
will require a bit of work--first selecting the IDs and weighting and
then randomly selecting quotes.
Any thoughts on a fast method for doing this?
Thanks
Ed Dressel