开发者

How do I count total of row in mysql without get Fatal error : Allowed memory

开发者 https://www.devze.com 2023-03-13 05:58 出处:网络
I got a problem Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 141954624 bytes) when to count all of row mysql table

I got a problem Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 141954624 bytes) when to count all of row mysql table

$query = $db->query("SELECT * FROM table");
$count = $db->num_rows($query);

echo $count;

Total rows about 17k and I got Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 14195462开发者_如何转开发4 bytes). Let me know, how to fix it.


You could change your SQL query to...

SELECT COUNT(*) AS `rows_count` FROM `table`;

Then you don't have to load such a large recordset to just then use a row counting function to get the number of rows.

0

精彩评论

暂无评论...
验证码 换一张
取 消