Hello,
I often host clients which have "bad" PHP/SQL code ; as for example
a "select *" + mysql_row_nums on a 200Mo table just to count lines...
So I add a little patch to throw a warning in case the result of mysql_query
is larger than a specified limit.
I use the setting "mysql.min_stored_data_before_warn" in php.ini, and the
result is :
[30-Mar-2008 04:39:56] PHP Warning: mysql_query() [<a
href='function.mysql-query'>function.mysql-query</a>]: Your query use
too much memory (202636 o) in /path/to/script.php on line 8
This patch seem "usefull" for me as PHP does not report the queries's memory
consumption. But maybe it should be done in mysqli and PDO extensions to ?
I'm not a "C developper", and the patch use the mysql internal struct, so
it's not really "clean". Maybe we can do it differently.
Thanks
Olivier
PS : sorry for my limited english.
Hi,
Olivier Bonvalet wrote:
Hello,
I often host clients which have "bad" PHP/SQL code ; as for example
a "select *" + mysql_row_nums on a 200Mo table just to count lines...So I add a little patch to throw a warning in case the result of
mysql_query
is larger than a specified limit.
I use the setting "mysql.min_stored_data_before_warn" in php.ini, and the
result is :
[30-Mar-2008 04:39:56] PHP Warning: mysql_query() [<a href='function.mysql-query'>function.mysql-query</a>]: Your query use
too much memory (202636 o) in /path/to/script.php on line 8This patch seem "usefull" for me as PHP does not report the queries's
memory
consumption. But maybe it should be done in mysqli and PDO extensions to ?I'm not a "C developper", and the patch use the mysql internal struct, so
it's not really "clean". Maybe we can do it differently.
From 5.3 one can compile ext/mysql and ext/mysqli with mysqlnd (comes
with PHP) instead of libmysql. mysqlnd uses the Zend MM and thus obeys
to the memory limit. You can even download ext/mysql and ext/mysqlnd
from a 5.3 source and replace ext/mysql in your source tree. Rebuild
configure with buildconf and then configure with --with-mysql=mysqlnd .
You get the functionality with 5.2 then too. Using mysqli with 5.2 needs
a small Zend patch (backport of 2 files from 5.3 due toe mysqli's
persistent connections).
Thanks
Olivier
PS : sorry for my limited english.
Regards,
Andrey