您的位置:68399皇家赌场 > 虚拟主机 > pt-osc使用壹则,pt-osc使用

pt-osc使用壹则,pt-osc使用

发布时间:2019-05-25 19:12编辑:虚拟主机浏览(148)

    pt-osc使用1则,pt-osc使用

    1.应用前备份

    mysqldump -uroot -p fission_statistics room_break_history > room_break_history_20170704.dump

    2.pt-osc执行DDL

    pt-online-schema-change --user='root' --host='localhost' --ask-pass --alter "CHANGE break_type break_type INT(11) NOT NULL,CHANGE app_id app_id INT(11) NOT NULL,CHANGE room_id room_id INT(11) NOT NULL,CHANGE from_user_id from_user_id INT(11) NOT NULL,CHANGE to_user_id to_user_id INT(11) NOT NULL,CHANGE content_type content_type INT(11) NOT NULL,CHANGE source_message source_message VARCHAR(1536) CHARSET utf8mb4 COLLATE utf8mb4_澳门皇家赌场55533网址 ,general_ci NOT NULL,CHANGE send_message send_message VARCHAR(1536) CHARSET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,CHANGE request_type request_type INT(4) NOT NULL,CHANGE handle_type handle_type INT(11) NOT NULL,CHANGE handle_uid handle_uid INT(11) NOT NULL,CHANGE create_time create_time DATETIME NOT NULL,DROP INDEX idx_from_user_id,ADD  INDEX idx_handle_time (handle_type, create_time)" D=fission_statistics,t=room_break_history --execute

    一.采取前备份 mysqldump -uroot -p fission_statistics room_break_history room_break_history_20170704.dump 2.pt-osc执行DDL pt-online-schema-ch...

    ./bin/pt-online-schema-change --user='root' --host='localhost' --ask-pass -S /tmp/mysql.sock --alter "ADD  INDEX idx_from_user_id (from_user_id,room_id,handle_type, create_time)" D=fission_statistics,t=room_break_history --dry-run --print

    2.pt-osc执行DDL

     

    2.pt-osc执行DDL

    3.只输出测试结果

        id  select_type  table               type    possible_keys     key               key_len  ref        rows  Extra                     
    ------  -----------  ------------------  ------  ----------------  ----------------  -------  ------  -------  --------------------------
         1  PRIMARY      <derived2>          ALL     (NULL)            (NULL)            (NULL)   (NULL)  3438331  (NULL)                    
         2  DERIVED      room_break_history  index   idx_from_user_id  idx_from_user_id  21       (NULL)  3438331  Using where; Using index  
    

    pt-online-schema-change --user='root' --host='localhost' --ask-pass --alter "CHANGE break_type break_type INT(11) NOT NULL,CHANGE app_id app_id INT(11) NOT NULL,CHANGE room_id room_id INT(11) NOT NULL,CHANGE from_user_id from_user_id INT(11) NOT NULL,CHANGE to_user_id to_user_id INT(11) NOT NULL,CHANGE content_type content_type INT(11) NOT NULL,CHANGE source_message source_message VARCHAR(1536) CHARSET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,CHANGE send_message send_message VARCHAR(1536) CHARSET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,CHANGE request_type request_type INT(4) NOT NULL,CHANGE handle_type handle_type INT(11) NOT NULL,CHANGE handle_uid handle_uid INT(11) NOT NULL,CHANGE create_time create_time DATETIME NOT NULL,DROP INDEX idx_from_user_id,ADD  INDEX idx_handle_time (handle_type, create_time)" D=fission_statistics,t=room_break_history --execute

    mysqldump -uroot -p fission_statistics room_break_history > room_break_history_20170704.dump

    改进:

    一.选用前备份

    1.使用前备份

    二.实行语句

    三.只输出测试结果

    ./bin/pt-online-schema-change --user='root' --host='localhost' --ask-pass -S /tmp/mysql.sock --alter "ADD  INDEX idx_from_user_id (from_user_id,room_id,handle_type, create_time)" D=fission_statistics,t=room_break_history --dry-run --print

    想想:将字段的nullable改为not null后,key_len变短了,是或不是将是还是不是为空的剖断逻辑加多到了数额上?

    mysqldump -uroot -p fission_statistics room_break_history > room_break_history_20170704.dump

    pt-online-schema-change --user='root' --host='localhost' --ask-pass --alter "CHANGE break_type break_type INT(11) NOT NULL,CHANGE app_id app_id INT(11) NOT NULL,CHANGE room_id room_id INT(11) NOT NULL,CHANGE from_user_id from_user_id INT(11) NOT NULL,CHANGE to_user_id to_user_id INT(11) NOT NULL,CHANGE content_type content_type INT(11) NOT NULL,CHANGE source_message source_message VARCHAR(1536) CHARSET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,CHANGE send_message send_message VARCHAR(1536) CHARSET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,CHANGE request_type request_type INT(4) NOT NULL,CHANGE handle_type handle_type INT(11) NOT NULL,CHANGE handle_uid handle_uid INT(11) NOT NULL,CHANGE create_time create_time DATETIME NOT NULL,DROP INDEX idx_from_user_id,ADD  INDEX idx_handle_time (handle_type, create_time)" D=fission_statistics,t=room_break_history --execute

    Execution Time : 17.182 sec
    Transfer Time : 0.001 sec
    Total Time : 17.184 sec

    本文由68399皇家赌场发布于虚拟主机,转载请注明出处:pt-osc使用壹则,pt-osc使用

    关键词: 68399皇家赌场 mysql