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

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
pjcvijay
Forum Commoner
Posts: 25
Joined: Tue Sep 09, 2008 6:12 am

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

Post 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.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

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

Post 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
Post Reply