php - Reading from a big table -


I want to read data from the table (or view) on SQL Server 2008R2 using PHP 5.4.24 and freetds 0.91 . In PHP, I write:

  $ ret = mssql_query (select 'mytable', $ Conn);   

Then I read a line at one time, took action on them, all right. Except, when the table is really big, I get an error:

  Fatal error: 1073741824 TIRED in the allowed memory size of the bytes / home / test / test (try to allocate 4625408 bytes done). An error occurs in Mssql_query (), so no matter how I query.  

It is not viable to change the query to return lower rows or lower columns, because I need to read a lot of data from multiple tables in a limited time.

To read PHP in one row in a row or to a proper number of times at once?

I agree with @ James in question comments, if you have a table reading such a large amount of your memory Before handing over the PHP to hide the results, it probably means that you need to know a better method though, here is a possible solution (untested and I have used MSSQL only a few times , But if not right then I Do your best):

  $ ret = mssql_query ('Total Lights' from mytable' SELECT COUNT (*), $ Conn); $ Line = mssql_fetch_row ($ ret); $ Offset = 0; $ Increase = 50; ($ Offset & lt; $ row ['TotalRows']) {$ ret_2 = mssql_query ("IDs offset offset by $ id of offset {$ offset} ROWS FETCH next {$ increment} ROWS ONLY", $ Conn); // // Loop on those 50 rows, do your work ... $ $ offset + = $ increment; } // // There will probably be one remaining, so you have to have an account for it later; It may be wise to make the interior loop a function or method. //    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

c++ - Qt::make_shared for creating QSharedPtr as std::make_shared for creating std::shared_ptr -