jeudi 5 décembre 2019

need help optimizing a sql statment using RAND()

I am currently working on a project that has a very large database of users and their different levels, however we where using RAND() and we are starting to get very high MySQL Cpu usage warnings from our webhost due to the growing demand of the database.

So we need to optimize this one particular query to help reduce the mysqli calls …

The row LINK where most of the data is stored is close to 50,000 + entries and using RAND() is slowly killing the website.

How would we optimize this to reduce the number of mysqli calls..

$CALLROW = $db->CacheGetAll("SELECT ID, TITLE FROM {$tables['link']['name']} WHERE (FEATURED = '1' OR FEATURED_ADVANCED= '1' OR FEATURED_NORMAL= '1') AND STATUS = '2' {$expire_where} ORDER BY RAND() LIMIT 20"); $tpl->assign('CALLROW', $CALLROW);

Any help would be extremely appreciated! Mr.X




Aucun commentaire:

Enregistrer un commentaire