Resolved
Written on
·
108
0
TEXT, LONGTEXT 타입 칼럼이 존재하는 테이블의 경우에 informatino_schema.TABLES에 존재하는 avg_row_length의 값은 LOB 칼럼들의 평균바이트 수도 같이 계산이 되는걸까요?
Answer 1
0
안녕하세요.
아래 예제에서와 같이, MySQL 서버의 avg_row_legnth
는 data_length / rows
값의 결과일뿐입니다. 그리고 data_length
값은 테이블의 데이터가 저장된 페이지의 개수 * 페이지크기(16KB)
입니다.
마지막으로 데이터가 저장된 페이지의 개수
에는 Off-page 또는 Inline으로 저장된 TEXT/BLOB 컬럼들도 모두 포함됩니다.
CREATE TABLE table_stats (id int primary key, fd text);
INSERT INTO table_stats VALUES (1, REPEAT('한글',10000));
SELECT id, length(fd) FROM table_stats;
+----+------------+
| id | length(fd) |
+----+------------+
| 1 | 60000 |
+----+------------+
ANALYZE TABLE table_stats;
+------------------+---------+----------+----------+
| Table | Op | Msg_type | Msg_text |
+------------------+---------+----------+----------+
| matt.table_stats | analyze | status | OK |
+------------------+---------+----------+----------+
SHOW TABLE STATUS LIKE 'table_stats' \G
*************************** 1. row ***************************
Name: table_stats
Engine: InnoDB
Version: 10
Row_format: Dynamic
Rows: 1
Avg_row_length: 81920
Data_length: 81920
Max_data_length: 0
Index_length: 0
Data_free: 0
Auto_increment: NULL
Create_time: 2025-02-02 07:06:31
Update_time: 2025-02-02 07:06:59
Check_time: NULL
Collation: utf8mb4_0900_ai_ci
Checksum: NULL
Create_options:
Comment:
1 row in set (0.00 sec)
설명이 길었는데, 결론은 TEXT/LONGTEXT
타입 컬럼도 모두 avg_row_length
에 영향을 미치게 됩니다.