Jump to content

Unable to save result set warning


phpknight

Recommended Posts

Hi,

 

I am purposely running a query that returns 14 million rows to test the limits of my program.  Once I ask for about 500,000 rows of this result at one time, I get a php warning that says "unable to save result set."  Also, the query fails and the error is "mysql server has gone away."  Which mySQL/php variables might I increase so that the query does not die?

 

Thanks!

Link to comment
Share on other sites

You shouldn't think in those terms. Instead, you should be looping and using LIMIT to get and process a chunk of data at a time.

 

i.e.

 

First query:  LIMIT 0, 100000

 

Second query: LIMIT 100000, 100000

 

Third query: LIMIT 200000, 100000

 

etc.

 

 

Link to comment
Share on other sites

This occurs becuase php cannot reserve enough memory for your result set. You could change the amount of memory that php can access but that approach would result in a massively slow system and would eat up quit a bit of ram from your system. I suggest you stick with the above suggestion and use limit to limit your results to what php can handle with out modification. Your system will run much faster and you will never get an error due to that lack of system resources.

Link to comment
Share on other sites

I understand your suggestions, and in production the program will not work like that.  However, I just want to make sure the capability is there if it gets big.  About the memory issue, I thought of that, but PHP is not throwing an over the memory limit warning or anything.  The script goes to completion, but the result set just does not get saved.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.