5 ms·
Be careful in using group_concat in mysql - it actually truncates the result to the max_len setting which is by default 1024 and will not tell you it truncates
by hunter23 8y ago
Be careful in using group_concat in mysql - it actually truncates the result to the max_len setting which is by default 1024 and will not tell you it truncates the result in the logs. it took us forever to find the cause of this issue in one of our batch jobs (I wish mysql issued a warning when truncating):
"In MySQL, you can get the concatenated values of expression combinations. To eliminate duplicate values, use the DISTINCT clause. To sort values in the result, use the ORDER BY clause. To sort in reverse order, add the DESC (descending) keyword to the name of the column you are sorting by in the ORDER BY clause. The default is ascending order; this may be specified explicitly using the ASC keyword. The default separator between values in a group is comma (,). To specify a separator explicitly, use SEPARATOR followed by the string literal value that should be inserted between group values. To eliminate the separator altogether, specify SEPARATOR ''.
The result is truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024. The value can be set higher, although the effective maximum length of the return value is constrained by the value of max_allowed_packet. The syntax to change the value of group_concat_max_len at runtime is as follows, where val is an unsigned integer"
https://dev.mysql.com/doc/refman/8.0/en/group-by-functions.html#function_group-concat https://dev.mysql.com/doc/refman/8.0/en/group-by-functions.h...
- geshan 8y agoThere is a setting to make it longer.
- hunter23 8y agoYes this is mentioned in the documentation I quoted.
- opless 8y agoThen clearly mysql isn't the database you want. Perhaps MSSQL or postgresql or even (spit) Oracle to name a few. All massively more capable than the toydb that is mysql. I think the trouble with most developers is that their experience is mostly with this terrible DB.