Home > Database > Mysql Tutorial > body text

MySQL大DML操作建议_MySQL

WBOY
Release: 2016-06-01 13:31:35
Original
880 people have browsed it

bitsCN.com

MySQL大DML操作建议

 

     ㈠ 大数据量INSERT

     

     ⑴ 使用多行插入代替单行:

 

insert into t values (),(),(),...
Copy after login

 LOAD DATA INFILE ... INTO TABLE t
Copy after login

 

     

     ⑶ 写入临时表、在 INSERT ... SELECT 

     

     ⑷ 取消索引、约束,等数据加载完后在重建

     

     ⑸ INSERT时指定DELAYED属性

     

     ⑹ 对于InnoDB、可以分散INSERT到多个事务、批量提交

     

     ㈡ 大数据量UPDATE

        

        这之前也应该disable掉索引和相关约束

        

     ① SELECT 唯一字段,变更字段

     ② 把结果集写入临时表

     ③ 为临时表创建复合索引

     ④ 循环临时表的每条记录

     ⑤ 依据临时表的唯一字段、更新目标表的变更字段

     

     ㈢ 大数据量DELETE

     

     ① 分区表

     ② 先把需要删除的数据的唯一标识取到临时表、游标循环批量delete

bitsCN.com
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!