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.
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. 라이선스 세부 정보