Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 |
Tags
- PETERICA
- 오블완
- golang
- kotlin
- CKA
- AI
- 공부
- 기록으로 실력을 쌓자
- APM
- minikube
- go
- SRE
- 티스토리챌린지
- Java
- Kubernetes
- tucker의 go 언어 프로그래밍
- 정보처리기사 실기 기출문제
- MySQL
- kotlin querydsl
- CloudWatch
- CKA 기출문제
- 코틀린 코루틴의 정석
- aws
- Pinpoint
- AWS EKS
- 바이브코딩
- Spring
- 컨텍스트 엔지니어링
- Linux
- kotlin coroutine
Archives
- Today
- Total
피터의 개발이야기
[MySQL] DB 용량 확인, 테이블별 용량 확인 본문
반응형

ㅁ 들어가면서
MySQL의 용량을 분석하기 위한 쿼리를 정리하였습니다.
update...
댓글의 질문 때문에 확인한 결과,
테이블이 뷰인 경유 용량과 건수는 null로 나타난다.
ㅁ 데이터베이스 용량 확인
SELECT
table_schema AS 'Database',
ROUND(SUM(data_length+index_length)/1024/1024, 1) AS 'Size(MB)'
FROM
information_schema.tables
WHERE
table_schema not in ('sys', 'mysql', 'information_schema', 'performance_schema')
GROUP BY table_schema
ORDER BY 2 DESC;

ㅁ 전체 용량 확인
SELECT
ROUND(SUM(data_length+index_length)/1024/1024, 1) AS 'Used(MB)',
ROUND(SUM(data_free)/1024/1024, 1) AS 'Free(MB)'
FROM
information_schema.tables;

ㅁ 테이블별 용량 확인
SELECT
table_schema AS 'DatabaseName',
table_name AS 'TableName',
ROUND(SUM(data_length+index_length)/(1024*1024), 2) AS 'All(MB)',
ROUND(SUM(data_length)/(1024*1024), 2) AS 'Data(MB)',
ROUND(SUM(index_length)/(1024*1024), 2) AS 'Index(MB)'
FROM
information_schema.tables
WHERE
TABLE_SCHEMA not in ('sys', 'mysql', 'information_schema', 'performance_schema')
GROUP BY table_schema, table_name
ORDER BY 3 DESC;

ㅇ 테이블 중에 current_dept_emp, dept_emp_latest_date은 뷰 테이블이기 때문에 null로 나타난다.
ㅁ 테이블별 Rows 확인
SELECT
table_schema AS 'DatabaseName',
TABLE_NAME,
TABLE_ROWS
FROM
information_schema.tables
WHERE
TABLE_SCHEMA not in ('sys', 'mysql', 'information_schema', 'performance_schema')
ORDER BY 3 DESC;

ㅇ 테이블 중에 current_dept_emp, dept_emp_latest_date은 뷰 테이블이기 때문에 null로 나타난다.
반응형
'Database > MySQL' 카테고리의 다른 글
| MySQL 콘솔 접속 방법 (0) | 2024.01.18 |
|---|---|
| [MySQL] Mysql Docker 설치, 8.0 (1) | 2023.08.22 |
| [MySQL] 대용량 샘플 데이터 사용하기 (0) | 2023.08.18 |
| [MySQL] 참고자료 목록 (0) | 2023.08.11 |
| [MySQL 튜닝] INSTR, LIKE, LOCATE, REGEXP 검색 속도 비교 (0) | 2023.08.10 |
Comments