GROUP_CONCAT in MySQL is quite a handy function and I have used it lots of times to solve problems in my professional life. And today I just used it to solve a memory issue I have in my PHP script which requires grouping of data.
It all worked OK if you work with very small data set, but problems will arise if you need to process hundreds of millions of rows of data – MySQL does not return all data set required in the GROUP BY and will simply truncate the data based on the
configuration in MySQL, and the default value is only 1024.
If you are working with a big data set, it is advised to set this config at run time so that you won’t get the unexpected behaviour:
SET GROUP_CONCAT_MAX_LEN = 100000;
Be mindful that although you can change the limit for GROUP_CONCAT, the upper limit is still controlled by the
, please refer to MySQL documentation
for more details.