HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Why set `group_concat_max_len` below the maximum?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
whythemaximumgroup_concat_max_lenbelowset

Problem

MySQL 5.5.28 on Ubuntu 12.04

If the result is longer than group_concat_max_len then the result is gracelessly truncated.

Currently I have a script that tries to check the required length ahead of time and sets group_concat_max_len to be large enough.

But the checking adds extra queries. Is there any downside to just setting group_concat_max_len to the maximum value? The upside is fewer queries.

Solution

I appreciate this question is a bit old now, but in case someone finds it and is wondering, one downside of setting the maximum (or an otherwise very large) value is that group_concat can return a blob rather than a varchar. Suggestions elsewhere say to set group_concat_max_len to 512 to make it always return a varchar rather than a blob. I tend to just cast it to char where necessary though.

Context

StackExchange Database Administrators Q#197746, answer score: 6

Revisions (0)

No revisions yet.