i am trying to pull a list from table, that list has special listings they are marked in ontop with “1” so they appears top but i want that the list never look like same so i want get little random from the list…(a bit randomized ontop )… i hope someone can understand what i am trying
but i know using rand() is very bad for performance. has yii2 any other solution ?
how many records do you have RAND() is the easiest way I can think of. if you dealing with small numbers then it should not be a problem. if you have large data set well in that case it could be problem or you can write the logic in PHP
I did a Classified app about 100,000 records every month use RAND() to list top listings on homepage and performance is pretty good
select distinct listing_id,(Select angebotsschwerpunkte from ms_listing where id = listing_id) angebotsschwerpunkte from ms_listing_stadt order by ontop desc, rand()