SQL Server 2008 returns “Memory limit of 10240 KB exceeded for buffered query”

女生的网名这么多〃 提交于 2019-11-30 02:37:58

问题


I'm trying to fill a HTML table with some SQL Server 2008 r2 data, the controller (php_sqlsrv) works fine, the tables are filled very well, but when I try to retrieve a 2000 or more rows (maybe less) it crashes and shows this message:

SQL Error: Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -59 [code] => -59 [2] => Memory limit of 10240 KB exceeded for buffered query [message] => Memory limit of 10240 KB exceeded for buffered query ))

How can I fix this? Is this a PHP or a sqlsrv problem? Can I fix this from the SQL Server Management Studio?


回答1:


Change the setting in php.ini.

Section: sqlsrv

Directive: sqlsrv.ClientBufferMaxKBSize.




回答2:


add two lines in php.ini

extension=php_pdo_sqlsrv_55_ts.dll
extension=php_sqlsrv_55_ts.dll
client_buffer_max_kb_size = '50240'
sqlsrv.ClientBufferMaxKBSize = 50240



回答3:


You can also change the settings during runtime if you do not require production server to have the php.ini changed (Check if this is applicable with your hosting).

Update the code with following lines:

ini_set('memory_limit','256M'); // This also needs to be increased in some cases. Can be changed to a higher value as per need)
ini_set('sqlsrv.ClientBufferMaxKBSize','524288'); // Setting to 512M
ini_set('pdo_sqlsrv.client_buffer_max_kb_size','524288'); // Setting to 512M - for pdo_sqlsrv

To check if your server supports this, try printing the values after setting the above.

echo ini_get('memory_limit');
echo ini_get('sqlsrv.ClientBufferMaxKBSize');
echo ini_get('pdo_sqlsrv.client_buffer_max_kb_size');

The new values should be the ones we had set in ini_set(). Else, the server does not support runtime configuration changes.



来源:https://stackoverflow.com/questions/27390793/sql-server-2008-returns-memory-limit-of-10240-kb-exceeded-for-buffered-query

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!