ColdFusion 9 - Top n random query results -
i've got series of queries 5 results @ random, problem is taking while through them, because involves loop assign rand value can order (which railo can in-query)
i wondering if has dealt , knows of way of speeding up.
i'm below 200ms, isn't bad i'm sure can sped up.
you don't need use qoq @ all.
one option might write original query as:
select top 5 whatever,you,need table order rand()
update syntax depending on database server you're using.
another option, done both regular queries , qoq, be:
- select primary keys
- shuffle array (i.e.
createobject("java","java.util.collections").shuffle(array)
) - use first 5 items in array select fields need.
no looping or updating, 2 simple selects.
of course if primary key auto-incrementing integer, might away select max(id)
use randrange
pick 5 items.
Comments
Post a Comment