简体   繁体   English

查询失败(使用mssql_query()和php时)

[英]Query failed in (while using mssql_query() and php)

My query: 我的查询:

$query_total = mssql_query("SELECT count(*) FROM table_name",$link);

The above query gives the error log: 上面的查询给出了错误日志:

PHP Warning:  mssql_query() [<a href='function.mssql-query'>function.mssql-query</a>]: Query failed in ...

Count of around 10 cr is expected with above query. 对于上述查询,预计大约10 cr的计数。

When I use the same query with limit of 100 ie: 当我使用限制为100的相同查询时,即:

$query_total = mssql_query("SELECT top 100 * FROM table_name",$link);

The above query runs successfully giving me the count. 上面的查询成功运行给我计数。

I have tried: 我试过了:

  1. mssql_get_last_message() , but I don't capture any logs. mssql_get_last_message() ,但我没有捕获任何日志。
  2. set_time_limit(0);
  3. ini_set("max_execution_time", 0);
  4. ini_set("memory_limit","16M");

Update 1: 更新1:

Even tried this, 甚至试过这个,

ini_set ( 'mssql.textlimit' , '65536' );
ini_set ( 'mssql.textsize' , '65536' );

Still not working. 还是行不通。

Please help on how can I get the heavy query executed. 请帮助我如何执行繁重的查询。

I think I got the solution: 我想我得到了解决方案:

I increased the memory limit to 512M and sql time out to 10min and then I could get the count of around 100 milloin rows. 我将内存限制增加到512M并将sql时间增加到10分钟,然后我可以获得大约100毫秒行的计数。

ini_set('memory_limit', '512M');
ini_set('mssql.timeout', 60 * 10); // 10 min

I don't know how much is 10cr, really, but it seems to fail in the sql server. 我不知道10cr是多少,真的,但它似乎在sql server中失败了。 Maybe running out of memory? 也许内存不足? What if you try count(id)? 如果你尝试计数(id)怎么办? You might need to configure your sql server differently for it to work, mind you. 您可能需要以不同的方式配置您的sql server以使其正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM