0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Mysql dump import で テーブルを高速 オプティマイザ

Posted at

Mysqlでは大量データーを削除後、テーブルサイズが変わらない時はオプティマイザが必要です。
optimize table tablename でもテーブルをオプティマイザできますが、時間かかる場合はあります。

  • オプティマイザ対象先の古いテーブルをdumpする
mysqldump -uwebmaster -h192.168.0.01 -pxxxxxxxxxx DATABASE_NAME table_name  > table_name.sql`
  • 万が一のため、古いテーブルをリネームする
ALTER TABLE table_name RENAME to table_name_old;
  • DumpしたSQLをインポートする
mysql -uwebmaster  -h192.168.0.01 -pxxxxxxxxxx DATABASE_NAME < ./table_name.sql
  • 古いテーブルを完全に削除する
drop table table_name_old;

これでtable_nameをオプティマイザできる

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?