Re: memory allocation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux