// mysql · sql behavior

group_concat_max_len

Longest result the GROUP_CONCAT function may return.

デフォルト
1024
Range
4 to 18446744073709551615 bytes (4294967295 on 32-bit platforms)
Restart needed
いいえ
Default checked on
MySQL 8.4 LTS

何ができるか

Anything longer is cut to the limit and the query returns the truncated string with a warning, not an error. The limit is counted in bytes, and the result is additionally capped by max_allowed_packet, so a very large value here cannot actually ship more than one packet.

デフォルト値

1024. 1024 bytes (MySQL 8.4), counted in bytes rather than characters.

Check the current value

SHOW GLOBAL VARIABLES LIKE 'group_concat_max_len';

SELECT VARIABLE_NAME, VARIABLE_SOURCE, MIN_VALUE, MAX_VALUE, SET_TIME
FROM performance_schema.variables_info
WHERE VARIABLE_NAME = 'group_concat_max_len';

Change it

SET SESSION group_concat_max_len = 1048576;   -- this connection
SET GLOBAL group_concat_max_len = 1048576;    -- new connections, until restart
SET PERSIST group_concat_max_len = 1048576;   -- new connections, and after restarts

No restart. SET GLOBAL (or SET PERSIST, which also survives restarts) applies to connections opened afterwards; existing connections keep their session value unless they SET it themselves.

When to change it

When GROUP_CONCAT output is visibly cut off, typically in report or export queries; set it in the session that runs them instead of globally.

What can go wrong

Truncation is silent apart from a warning, so reports can ship incomplete lists without anyone noticing. Large values let one query return megabytes, which flows through max_allowed_packet to client memory, so size it to what the caller really consumes.

Questions about group_concat_max_len

What is the default value of group_concat_max_len in MySQL?

1024. 1024 bytes (MySQL 8.4), counted in bytes rather than characters.

Does changing group_concat_max_len require a restart?

No. No restart. SET GLOBAL (or SET PERSIST, which also survives restarts) applies to connections opened afterwards; existing connections keep their session value unless they SET it themselves.

When should I change group_concat_max_len?

When GROUP_CONCAT output is visibly cut off, typically in report or export queries; set it in the session that runs them instead of globally.

Back to all MySQL settings, or check the MySQL manual for every option.

// one client for every engine

Check group_concat_max_len on your own server

SQLly runs the query above against MySQL and the other engines in this reference, from one desktop app on macOS, Windows and Linux.

このページのテキストとデータ: CC BY 4.0、出典は SQLly (sqlly.app) と明記してください。 コードと SQL スニペット: MIT. ライセンスの詳細