I have a cronjob that runs a PHP script against MySQL. The script takes 5 minutes to process 4000 records (approximately 12 records per second). Here are the top two entries from top: PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME CPU COMMAND 8671 mysql 25 0 20172 19M 2000 R 97.8 3.9 2:02 0 mysqld 8670 appmgr 15 0 2088 2088 1424 S 2.2 0.4 0:03 0 php
Is there a way that I can slow down the script so mysqld does not bog the machine down.
Here is a snippet of code. The function is called by the cronjob. <snip> function rank_mailbox_current($company_ID){ $query = "select app_ID from mailbox where company_ID = \"$company_ID\" and deleted_date = 0 order by mailbox.ID desc"; $result=query_database($query);
while ($row = mysql_fetch_assoc($result)){ $app_ID = $row["app_ID"]; $rank_of_app=rank_app($app_ID,$company_ID); } } </snip>
Well, that snippet doesn't really show us much. Actually, unless there's a return() hidden in there somewhere, it's not actually doing anything but wasting time. What are you doing with the data? What is your table structure? Where are you indexes? Sounds like you have some nested queries or something...
-- ---John Holmes...
Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/
php|architect: The Magazine for PHP Professionals – www.phparch.com
-- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php