Page 1 of 1

Took long time (appx.15 min) & 10MB memory to display result

Posted: Wed Sep 30, 2009 11:23 pm
by pjcvijay
pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


Dear Friends,

I execute the following scripts, it took almost 15 minutes and 10MB Memory to display the contents. I would like to solve this problem without using too much memory and long delay. 'SELECT * from employees_salary WHERE emid=1' will return 6015 records. Please help me to solve this problem. How to optimize the following script.

Code: Select all

$link=mysql_connect('localhost','root','…
if(!$link){
die("Not connected".mysql_error());
}
$db=mysql_select_db('auto3',$link);
if(!$db) {
die("DB Does not Exits".mysql_error());
}
$sql = 'SELECT * from employees_salary WHERE emid=1';
$result = mysql_query($sql);
 
while ($row=mysql_fetch_row($result)) {
echo '<pre>';
print_r($row);
echo '</pre>';
}
}
 
Thanks in advance,
Vijay


pickle | Please use [ code=php ], [ code=text ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.

Re: Took long time (appx.15 min) & 10MB memory to display result

Posted: Thu Oct 01, 2009 5:28 am
by josh
You could start by moving your <pre> tags out of the loop, and then you could read the forum stickies before posting more code :D