FAT47の底辺インフラ議事録

学んだことのメモ帳です

MySQLでテーブルにindex貼るときbufferに載せる

まずはテーブルのデータサイズ確認。

mysql >show table status like 'テーブル名' \G;

*************************** 1. row ***************************
           Name: テーブル名
         Engine: InnoDB
        Version: 10
     Row_format: Compact
           Rows: 798021
 Avg_row_length: 100
    Data_length: 80462672
Max_data_length: 0
   Index_length: 0
      Data_free: 4194304
 Auto_increment: NULL
    Create_time: 2013-03-12 13:17:34
    Update_time: NULL
     Check_time: NULL
      Collation: utf8_general_ci
       Checksum: NULL
 Create_options: 
        Comment: 
1 row in set (0.00 sec)

buffer poolに載せても大丈夫か、空き容量を確認する。

mysql >show engine innodb status;

Buffer pool size   786431
Free buffers       683895

今回はほとんど空いてるので大丈夫そう。

全件SELECT回して、

select count(*) from hoge_table_name;

INDEX貼る。

create index ***on hoge_table_name(key);