MySQL Forums
Forum List  »  PHP

Re: Time-out problem
Posted by: Peter Brawley
Date: April 23, 2014 09:57AM

2 million rows is not a lot.

But (i) executing a new query for every value found in your first query is a waste of resources. You could easily do it with one query, and (ii) the mysql API has been deprecated and will disappear, you need to use mysqli ...

$conn = mysqli_connect(...);
$res1 = mysqli_query($conn,'select id_campaign from spd_campaign');

$ids = array();
while( $row=mysqli_fetch_row($res1) ) $ids[] = $row;
$sid = implode( ",", $ids );

$qry="
select fk_id_ad_format
from spd_unit
join spd_ad on fk_id_ad=id_ad
where fk_id_campaign in($isid)
group by fk_id_ad_format";
$res2=mysqli_query($conn,$qry);

Then retrieve & display the result as desired.

Options: ReplyQuote


Subject
Written By
Posted
April 23, 2014 08:04AM
Re: Time-out problem
April 23, 2014 09:57AM
April 23, 2014 10:27AM
April 25, 2014 02:26PM
April 28, 2014 11:49AM
April 30, 2014 11:15AM
April 30, 2014 11:32AM
April 30, 2014 11:47AM
May 01, 2014 08:00AM
April 30, 2014 01:12PM
May 02, 2014 10:40AM
June 06, 2014 05:13AM
June 06, 2014 09:15AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.