I tried to store an array containing about 50000 keys and respective values to the user meta using update_user_meta. Since, this was only a test, I ran a for loop to generate the array.
$test = array ();
for ($i = 0; $i <= 50000; $i++) {
$test[$i] = $i;
}
update_user_meta($user_id, 'test', $test);
I ended up getting the error WordPress database error: [MySQL server has gone away]. Eventually, I was able to get it working with an array size of 48000 keys. Since update_user_meta converts arrays to serialized data before storing, is there a limit to the serialized data that user meta or post metas can handle? Or does this happen due to some other issue?
I tried the timeout fix suggested here. But I am not sure if it is supposed to work for WP 3.3.1. or whether if at all it is solution to my problem.
Please note I am using a local dev install using MAMP.
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
According to the DB schemea, the meta_value column is of type longtext, and that has a maximum size of 4GB, however you’re unlikely to reach that.
Eitherway storing large quantities of data in a single field is bad both from a practical point of view, a performance point of view, and data storage.
I advise instead you use a custom taxonomy for this kind of data ( yes taxonomies aren’t just for post objects )
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0