Jump to content

Fatal error: Maximum execution time of 30 seconds exceeded


krizzangel

Recommended Posts

i have a problem with my query where the time limit exceeded (30secs).

heres my code:

 

$query = "select COUNT(*) as doble, product_s_desc as model_no from jos_vm_product group by product_s_desc having doble > 1";

 

$result = mysql_query($query);

 

while($row = mysql_fetch_array($result)) {

$s_desc = $row[1];

 

$query2="select product_sku, MAX(wintron_price) from jos_wintron_ebay where product_sku in (select product_sku from

jos_vm_product where product_s_desc='$s_desc') group by product_sku limit 1";

$result2= mysql_query($query2);

 

while($row2 = mysql_fetch_array($result2)){

$sku = $row2[0];

$update ="update jos_vm_product set product_publish ='N' where product_sku ='$sku'";

mysql_query($update);

 

}

}

 

 

anyone suggesting a better code? what i need is to change the publish value for duplicate items.

Link to comment
Share on other sites

As you are having 2 while loops, it is going in loop execution reaching the max execution time. For that you can check your queries which will return minimum records, which will let you know that queries are proper. Also you can try to optimize your queries. Or else you have to increase you execution time.

Link to comment
Share on other sites

Running a query in a loop - never a good thing and hardly ever a necessity.

 

Additionaly inner loop has a subquery in WHERE clause, which is very inefficient in MySQL.

 

Query below should give you expected results:

SELECT 
  e.product_sku, MAX(e.wintron_price) 
FROM 
  jos_wintron_ebay AS e 
INNER JOIN (
  SELECT 
    product_sku 
  FROM
    jos_vm_product AS p 
  INNER JOIN (
    SELECT 
      COUNT(*) AS doble,
      product_s_desc
    FROM 
      jos_vm_product 
    GROUP BY 
      product_s_desc 
    HAVING 
      doble > 1
    ) AS p1 
    ON 
      p.product_s_desc=p1.product_s_desc
  ) AS p 
ON 
  e.product_sku = p.product_sku 
GROUP BY 
  e.product_sku 
LIMIT 1

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.