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:

  1. select primary keys
  2. shuffle array (i.e. createobject("java","java.util.collections").shuffle(array))
  3. 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

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -