Apparently something here is causing 2gb of RAM to be eaten. The site averages 40K page views per day. <?php $more['query'] = mysql_query("SELECT * FROM " . $prefix_db . "data ORDER BY RAND() LIMIT 20"); $more['row'] = mysql_fetch_assoc($more['query']); ?> <ul> <?php do { ?> <li> <?php echo strip_tags($more['row']['text']); ?> </li> <?php } while ($more['row'] = mysql_fetch_assoc($more['query'])); ?> </ul> PHP: Is this a bad way of fetching MySQL rows? Is there a more RAM efficient way? Thanks!
Hi, Why do you request * and not only the fields you are using? b.t.w RAND() is also not the way to go! http://forums.mysql.com/read.php?24,163940,163940
1. why you are capturing the mysql results into a array. use a variable. Arrays could cause lots of memory being used. Try this.. $result = mysql_query("SELECT * FROM " . $prefix_db . "data ORDER BY RAND() LIMIT 20"); $rows = mysql_fetch_assoc($result); 2. Rand() infact may slow down the mysql, but only if you have huge number of records. if you have fewer records in your table, then it shouldnt be a problem.