삽질/개발,엔지니어링

mysql table 복구 (repair table)

maengis 2024. 1. 29. 13:21

테이블 하나가 손상 되었는지 조회가 너무 오래 걸렸다.

 

mysql> select * from 테이블 where 컬럼 = '조건';
-------
1 row in set (49.88 sec)

mysql> select count(*) from 테이블;
+----------+
| count(*) |
+----------+
|     1540 |
+----------+
1 row in set (13.06 sec)

 

1,540건 있는 데이터 전체 조회에 13초. 인덱스 걸린 거 하나 가져오는데 49초.

 

문제 있나 확인해 보면 멀쩡하다고 나옴.

mysql> check table 테이블;
+-------------------------+-------+----------+----------+
| Table                   | Op    | Msg_type | Msg_text |
+-------------------------+-------+----------+----------+
| 데이터베이스.테이블       | check | status   | OK       |
+-------------------------+-------+----------+----------+
1 row in set (0.02 sec)

 

repair table로 해결.

 

mysql> repair table 테이블;
+-------------------------+--------+----------+---------------------------------------------------------+
| Table                   | Op     | Msg_type | Msg_text                                                |
+-------------------------+--------+----------+---------------------------------------------------------+
| 데이터베이스.테이블       | repair | note     | The storage engine for the table doesn't support repair |
+-------------------------+--------+----------+---------------------------------------------------------+
1 row in set (44 min 20.59 sec)

mysql> select count(*) from 테이블;
+----------+
| count(*) |
+----------+
|     1540 |
+----------+
1 row in set (0.01 sec)
반응형