Re: memory allocation
| From: | shiplu | Date: | Tue, 25 Sep 2012 12:23:24 +0000 |
| Subject: | Re: memory allocation | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-319251@lists.php.net to get a copy of this message | ||
I would like to see how you are reading data from database?
There are many ways to reduce memory usage. Here is a very common way
reduce memory.
instead of
$res = mysql_query("select * from table1 limit 10000000");
while($row = mysql_fetch_assoc($res)){
/// process row.
}
Do this,
for($x = 0; $x< 10000000; $x+=100;}
$res = mysql_query(sprintf("select required_col1, required_col2,
... from table1 limit %d, %d",$x, 100));
while($row = mysql_fetch_assoc($res)){
/// process row.
}
}
--
Shiplu.Mokadd.im
ImgSign.com | A dynamic signature machine
Innovation distinguishes between follower and leader