Я сделал свой код с помощью photo mysql но я беру более 7 часов в исполнении пожалуйста направьте меня для сокращения времени
ini_set('max_execution_time', 15000); ini_set("memory_limit","1028M"); mysql_query('TRUNCATE TABLE scrip_average'); $sql_all = mysql_query("select * From all_scrip limit 8000"); while($row_all = mysql_fetch_array($sql_all)) { $SC_CODE=$row_all['SC_CODE']; $sql_last = mysql_query("select * From scrip where SC_CODE='$SC_CODE' ORDER BY ID DESC LIMIT 1"); while($row_last = mysql_fetch_array($sql_last)) { $LAST_OPEN=$row_last['OPEN']; $LAST_HIGH=$row_last['HIGH']; $LAST_CLOSE=$row_last['CLOSE']; $LAST_LOW=$row_last['LOW']; } for ($n = 200; $n >0; $n--) { $total_OPEN=0; $total_HIGH=0; $total_LOW=0; $total_CLOSE=0; $result_open=mysql_query("SELECT SUM(OPEN) AS total_value FROM scrip where SC_CODE='$SC_CODE' ORDER BY ID DESC LIMIT $n"); $total_OPEN=mysql_result($result_open,0,0); $result_high=mysql_query("SELECT SUM(HIGH) AS total_value FROM scrip where SC_CODE='$SC_CODE' ORDER BY ID DESC LIMIT $n"); $total_HIGH=mysql_result($result_high,0,0); $result_low=mysql_query("SELECT SUM(LOW) AS total_value FROM scrip where SC_CODE='$SC_CODE' ORDER BY ID DESC LIMIT $n"); $total_LOW=mysql_result($result_low,0,0); $result_close=mysql_query("SELECT SUM(CLOSE) AS total_value FROM scrip where SC_CODE='$SC_CODE' ORDER BY ID DESC LIMIT $n"); $total_CLOSE=mysql_result($result_close,0,0); $total_OPEN=$total_OPEN/$n; $total_HIGH=$total_HIGH/$n; $total_LOW=$total_LOW/$n; $total_CLOSE=$total_CLOSE/$n; $LOW_status='negetive'; if($total_LOW>$LAST_LOW) { $LOW_status='possitive'; } $HIGH_status='negetive'; if($total_HIGH>$LAST_HIGH) { $HIGH_status='possitive'; } $OPEN_status='negetive'; if($total_OPEN>$LAST_OPEN) { $OPEN_status='possitive'; } $CLOSE_status='negetive'; if($total_CLOSE>$LAST_CLOSE) { $CLOSE_status='possitive'; } $data=array( 'date'=>$n, 'SC_CODE'=>$SC_CODE, 'OPEN'=>$total_OPEN, 'HIGH'=>$total_HIGH, 'LOW'=>$total_LOW, 'CLOSE'=>$total_CLOSE, 'LOW_status'=>$LOW_status, 'HIGH_status'=>$HIGH_status, 'OPEN_status'=>$OPEN_status, 'CLOSE_status'=>$CLOSE_status); //'img_postdate' =>date("y,m,d"), $query=insert("scrip_average",$data); } }
Что я уже пробовал:
Это занимает слишком много времени в исполнении пожалуйста помогите мне сократить время выполнения