简体   繁体   中英

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.

When I use the same query with limit of 100 ie:

$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.
  2. set_time_limit(0);
  3. ini_set("max_execution_time", 0);
  4. ini_set("memory_limit","16M");

Update 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.

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. Maybe running out of memory? What if you try count(id)? You might need to configure your sql server differently for it to work, mind you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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